ManouHH
ManouHH

Reputation: 149

Load content into TinyMCE

In advance thank you all for your help.

I want to load content into a TinyMCE textfield.

My code looks like this:

    <?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>

As you can see I did value=" in the textfield, but that doesnt seem to work. Can someone please tell me how to do this?

Upvotes: 2

Views: 1905

Answers (1)

Orangepill
Orangepill

Reputation: 24645

The content of a textarea is enclosed within textarea tags like:

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

Upvotes: 7

Related Questions