将内容加载到TinyMCE中

时间:2013-06-12 02:17:20

标签: php javascript html mysql tinymce

事先感谢大家的帮助。

我想将内容加载到TinyMCE文本字段中。

我的代码如下所示:

    <?php
    require_once('adminmenu.php');
    $articleid = $_GET['id'];
    require_once('core/dbconnect.php');

    $qarticles = mysql_query("SELECT * FROM news WHERE id='$articleid' ORDER BY date DESC");
    $row = mysql_fetch_array($qarticles);
    $date = $row['date'];
    $title = $row['title'];
    $shorttitle = $row['shorttitle'];
    $content = $row['content'];
    ?>

    <script src="http://tinymce.cachefly.net/4.0/tinymce.min.js"></script>
    <script>
        tinymce.init({selector:'textarea'});
    </script>

    <form name="form" method="post" action="articleedit.php?id=<?php echo $id; ?>" onsubmit="return confirm('Are you sure you want to change article?')">
        <p>
            <label for="newsmgstitle"></label>
            <label for="newsmsgdatetime"></label>
        </p>
        <table border="0">
            <tr>
                <td colspan="2" bgcolor="#000000" style="font-weight: bold; color: #FFF;">NEW NEWS ARTICLE</td>
            </tr>
            <tr>
                <td><strong>TIME & DATE</strong></td>
                <td><input type="text" name="newsmsgdatetime" id="newsmsgdatetime" size="25" value="<?php echo $date; ?>"</td>
            </tr>
            <tr>
                <td><strong>TITLE</strong></td>
                <td><input type="text" name="newsmgstitle" id="newsmgstitle" size="50" value="<?php echo $title; ?>"></td>
            </tr>
            <tr>
                <td><strong>SHORT TITLE</strong></td>
                <td><input type="text" name="newsmsgshortitle" id="newsmsgshortitle" size="25" maxlength="25" value="<?php echo $shorttitle; ?>"></td>
            </tr>
            <tr>
                <td colspan="2"><strong>ARTICLE</strong><br>
                    <textarea name="newsmsg" id="newsmsg" cols="80" rows="20" value="<?php echo $content; ?>"></textarea></td>
            </tr>
            <tr>
        <td colspan="2"><input type="submit" name="submitnewsmsg" id="submitnewsmsg" value="PUBLISH ARTICLE"></td>
            </tr>
        </table>
    </form>

正如你所看到的那样,我在文本字段中做了值=“但这似乎没有用。有人可以告诉我该怎么做吗?

1 个答案:

答案 0 :(得分:5)

textarea的内容包含在textarea标签中,如:

<textarea name="newsmsg" id="newsmsg" cols="80" rows="20" ><?= htmlspecialchars($content); ?></textarea>