alexander007 Posted October 12, 2007 Share Posted October 12, 2007 HOw I can load the content for the area from a database using a dropdown menu? I try but i cant makeit o work... heres the sample code from tinymce wiki... tinyMCE.init({ mode : "textareas", theme : "advanced" }); function ajaxLoad() { var inst = tinyMCE.getInstanceById('content'); // Do you ajax call here inst.setHTML('HTML content that got passed from server.'); } function ajaxSave() { var inst = tinyMCE.getInstanceById('content'); // Do you ajax call here alert(inst.getHTML()); } Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/ Share on other sites More sharing options...
sKunKbad Posted October 12, 2007 Share Posted October 12, 2007 First you have to connect to the database, then you have to query the database and retrieve the data, then you insert the data into your textarea. You need a database connection script and query first. Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-367616 Share on other sites More sharing options...
alexander007 Posted October 12, 2007 Author Share Posted October 12, 2007 yeah I know that...I try that...but the problem is that Im only retreaving only one value... Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-367620 Share on other sites More sharing options...
sKunKbad Posted October 12, 2007 Share Posted October 12, 2007 if you need more of your rows to print, then you have to loop through the results of your query. Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-367631 Share on other sites More sharing options...
sKunKbad Posted October 12, 2007 Share Posted October 12, 2007 Something like this: $sql = mysql_query("SELECT * FROM table WHERE type = 'stinky'") ; while ($row = mysql_fetch_array($sql)){ extract ($row); echo "<strong>$name</strong>"; } Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-367637 Share on other sites More sharing options...
alexander007 Posted October 12, 2007 Author Share Posted October 12, 2007 This is my code...Im using radio buttons... <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Manejador de Contenidos</title> <?php require_once("../include/header.inc.php"); require_once( DIRECTORY_PATH_INC . 'utils.inc.php'); require_once( DIRECTORY_PATH_INC . 'db.inc.php'); global $contenido; function LoadGreeting(){ $contenido = "Este es el Manejador de Contenidos de su Pagina Seleccione del Menu"; echo $contenido; } function ContentLoad(){ echo $_POST['Categories']; if ($_POST['Categories'] = "Main Page") $category = "Main Page"; if ($_POST['Categories'] = "Tour") $category = "Tour"; echo $category; $query = "SELECT `Contenido` FROM `Content` WHERE `Category` = '$category'"; $contenido = db_value($query); echo $contenido; } function SaveContent2(){ $query = "UPDATE `Content` SET `Contenido`= '$newContent' WHERE `ID` = 1"; $greeting = db_res($query); echo "Contenido Guardado"; } ?> <script type="text/javascript" src="../plugins/tiny_mce/tiny_mce_src.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", theme : "advanced", plugins : "fullpage", theme_advanced_buttons3_add : "fullpage" }); function Load() { var inst = tinyMCE.getInstanceById('content'); inst.setHTML('<?php ContentLoad();?>'); } function Save() { var inst = tinyMCE.getInstanceById('content'); tinyMCE.triggerSave(true,true); //alert(inst.getHTML()); } function saveContent(content, id) { alert('The content for "' + id + '" has been saved'); http.open("GET", "save_content.php?id=" + id + "&content=" + escape(content), true); http.onreadystatechange = handleHttpResponse(id); http.send(null); } </script> </head> <body> <form id="form1" name="form1" method="post" action=""> <p> <label> <input type="radio" name="Categories" value="Main Page" id="Categories_0" /> Main Page</label> <br /> <label> <input type="radio" name="Categories" value="Tour" id="Categories_1" /> Tour</label> <br /> </p> <input type="button" value="Cargar" onclick="Load();" /> <input name="Reset" type="reset" value="Comenzar de Nuevo" /> </form> <textarea id="content" name="content" cols="85" rows="25" class="mceAdvanced"><?php LoadGreeting();?></textarea><br /> <input type="button" value="Save" onclick="saveContent(inst.getHTML(), 1)" /> <!--<form method="post" action="edit_content.php"> name="cat" onclick="Load();" <input type="button" value="Load" onclick= "Load();" /> <textarea name="index_content" cols="90" rows="15">Wooo This is some content that will be editable with TinyMCE.</textarea> <input type="submit" value="Submit" /> </form> --> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-367955 Share on other sites More sharing options...
alexander007 Posted October 12, 2007 Author Share Posted October 12, 2007 any idea? Quote Link to comment https://forums.phpfreaks.com/topic/72886-phpajaxmysql-and-tinymce/#findComment-368254 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.