【问题标题】:Getting tinymce to display what I type withing the textarea?让tinymce显示我在textarea中输入的内容?
【发布时间】:2013-03-02 14:12:24
【问题描述】:

目前我能够将内容发布到数据库并通过 SQL 查询检索此内容。

不幸的是,当我检索到内容时,它会在网页上显示

<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 变量和 $string 变量。

【问题讨论】:

    标签: php html tinymce textarea tinyxml


    【解决方案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;
    

    【讨论】:

    • 抱歉,这不起作用,您能提供另一种方法吗?谢谢
    • 如果你可以检查一下,我已经在我的帖子中编辑了代码。
    猜你喜欢
    • 2011-03-28
    • 1970-01-01
    • 1970-01-01
    • 2016-04-02
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 2017-11-23
    • 1970-01-01
    相关资源
    最近更新 更多