2013-03-02 39 views
1

目前我能夠將內容發佈到數據庫並通過SQL查詢檢索此內容。使用tinymce顯示我使用textarea鍵入的內容?

不幸的是,當我做檢索內容顯示爲等網頁

<p>Shaun this is the record</p> <p>The next line of the r... 

我明白,這是最有可能與配置做的,我已經嘗試了幾種解決方案,但都失敗了。

有人可以指示我,我應該在我的配置?

這裏是我當前的配置看起來像,它是簡單地放置php文件的標籤內:

<head> 
<script language="javascript" type="text/javascript" src="/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> 
<script language="javascript" type="text/javascript"> 
tinyMCE.init({   
      theme : "advanced",  
      mode : "textareas", 
      encoding : "xml"}); 
</script> 
</head> 

感謝您的時間,任何解決方案將是太棒了!

$sql = "SELECT * ". 
    "FROM podContent ORDER BY id DESC ". 
    "LIMIT $offset, $rec_limit "; 

$podText = htmlspecialchars_decode($row['imageName']); 

$retval = mysql_query($sql, $con); 
if(! $retval) 
{ 
    die('Could not get data: ' . mysql_error()); 
} 
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) 
{ 
echo "<div class=\"pods\">"; 
echo "<a href=\"/page.php?id={$row['id']}\">"; 
echo "<div class=\"podHeading\">"; 
echo "{$row['heading']}</a> <br> "; 
echo "</div>"; 
echo "<div class=\"podImage\">";  
echo "<img src=\"images/{$row['imageName']}\">"; 
echo "</div>"; 

$string = $podText; 
if(strlen($string) > 100) { 
echo substr($string, 0, 100).'...'.$hyperlink;} 
else { 
echo $string; 

}

你應該尋找$ podText變量和$字符串變量。

回答

1

您可以使用一個PHP函數,這些字符解碼回來就好

$variable_to_display = htmlspecialchars_decode($variable_from_database); 

試試這個

$sql = "SELECT * ". 
    "FROM podContent ORDER BY id DESC ". 
    "LIMIT $offset, $rec_limit "; 



$retval = mysql_query($sql, $con); 
if(! $retval) 
{ 
    die('Could not get data: ' . mysql_error()); 
} 
while($row = mysql_fetch_array($retval, MYSQL_ASSOC)) 
{ 

echo "<div class=\"pods\">"; 
echo "<a href=\"/page.php?id={$row['id']}\">"; 
echo "<div class=\"podHeading\">"; 
echo "{$row['heading']}</a> <br> "; 
echo "</div>"; 
echo "<div class=\"podImage\">";  
echo "<img src=\"images/{$row['imageName']}\">"; 
echo "</div>"; 

$podText = htmlspecialchars_decode($row['imageName']); 

$string = $podText; 
if(strlen($string) > 100) { 
echo substr($string, 0, 100).'...'.$hyperlink;} 
else { 
echo $string; 
+0

抱歉,這是行不通的,你能爲我提供了另一種方式?謝謝 – AyeTry 2013-03-02 14:34:55

+0

你是如何使用這個函數的,你可以發佈該代碼。 – 2013-03-02 14:55:19

+0

我已經編輯了我的帖子中的代碼,如果你可以檢查出來。 – AyeTry 2013-03-02 15:08:00

相關問題