Results 1 to 2 of 2

Thread: Rich text editor - loading database text with php

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Rich text editor - loading database text with php

    1) Script Title: Rich Text Editor (for textareas)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...itor/index.htm

    3) Describe problem: I am wondering if it is possible to load text that is in a mysql database with PHP into the text box? Thanks in advance.

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You can, and all you have to do is like so:

    Code:
    <?php
    $id = $_GET['id'];
    
    include('dbconnect.php'); //all the database info and connection
    
    $info = mysql_query("SELECT * FROM `table` WHERE `id`='$id'");
    
    while ($q = mysql_fetch_array($info)) {
    ?>
    
    <script language="JavaScript" type="text/javascript">
    <!--
    //Usage: writeRichText(fieldname, html, width, height, buttons, readOnly)
    writeRichText('rte1', '<?php echo htmlentities($q["content"]);?>', 400, 200, true, false);
    //-->
    </script>
    
    <?php
    }
    ?>
    Just an example of course, but you get the idea. Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •