PDA

View Full Version : Rich text editor - loading database text with php



cturner
07-15-2007, 06:22 AM
1) Script Title: Rich Text Editor (for textareas)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex16/richtexteditor/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.

thetestingsite
07-15-2007, 04:08 PM
You can, and all you have to do is like so:



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