Spartan 117 Posted March 9, 2007 Share Posted March 9, 2007 Hello, I have a simple html editor on my page that edits the left portion of my page. I wanted to know if I could make the left side of the page load the html from the textbox as I change the html in the textbox. Here is my code for the editing and such: <?php // Database connection here include('config.php'); // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); $sql = "SELECT * FROM page_links WHERE id='1'"; $res = mysql_query($sql) or die (mysql_error()); $r = mysql_fetch_assoc($res); $check = mysql_num_rows($res); // check to make sure your id exists if($check > 0){ // convert all fields to strip slashes and line breaks to <br> $links = nl2br(stripslashes($r['links'])); ?> <p align="center"> <textarea name="pagelinks" cols="50" rows="20" id="pagelinks"><?=$links ?> </textarea> <?php } else { // show this if ID does not exist echo "<p align=center><font color=\"FFFFFF\"><b>There is an error in your database.<b></font></p>"; ?> <?php } ?> </p> <p align="center"> <input name="submit" type="submit" id="submit" value="Edit Links"> </p> </form> <p align="center"> <?php if ($_POST['submit'])//($_POST["$submit"]) { $newlinks = $_POST['pagelinks']; $sql = "UPDATE page_links SET links='$newlinks' WHERE id='1'"; $result = mysql_query($sql); echo "Links Updated!"; echo '<META HTTP-EQUIV="Refresh" Content="0; URL=linkeditor.php">'; } ?> Is it possible to make the links on the left equal the code in the textbox as I change it without submitting? Link to comment https://forums.phpfreaks.com/topic/41969-page-editor-preview-as-change/ Share on other sites More sharing options...
Glyde Posted March 9, 2007 Share Posted March 9, 2007 Well, since the "left side of the page" is not on the same page as the editor, you can't use any simple JavaScript. You'd have you implement some AJAX on your editor and display page. However, that means that if you type something in, it'll update in the database, regardless of whether or not you push submit. Overall, this is a little impractical. Link to comment https://forums.phpfreaks.com/topic/41969-page-editor-preview-as-change/#findComment-203481 Share on other sites More sharing options...
Spartan 117 Posted March 9, 2007 Author Share Posted March 9, 2007 Ok, thanks, I wish I could do this, oh well. Link to comment https://forums.phpfreaks.com/topic/41969-page-editor-preview-as-change/#findComment-203522 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.