Hi
I am experimenting with mySQL and PHP and now a bit lost. I have the data in a mySQL database and have integrated FCKeditor correctly. But now I simply want to have a textbox above the FCKeditor window with the database field topic's contents displayed. If the topic changes then I need the system to update the database.
Anyone able to help?
I am experimenting with mySQL and PHP and now a bit lost. I have the data in a mySQL database and have integrated FCKeditor correctly. But now I simply want to have a textbox above the FCKeditor window with the database field topic's contents displayed. If the topic changes then I need the system to update the database.
Code:
<?php
// Connect to the database
$cnx = mysql_connect("localhost", "root", "password")
OR die("Unable to connect to database!");
mysql_select_db("database", $cnx);
?>
<?php
if ($_POST['submit_form'] == 1)
{
// Save to the database
$details = mysql_real_escape_string(trim($_POST['fcktext']));
$result = mysql_query("UPDATE instructions SET details = '".$details."' WHERE id = 1");
mysql_query("UPDATE instructions SET udate = NOW() WHERE id = 1");
mysql_query("UPDATE instructions SET utime = NOW() WHERE id = 1");
if (!$result)
die("Error saving the record! Mysql said: ".mysql_error());
// Redirect to self to get rid of the POST
header("Location: editor.php");
}
?>
<?php include_once("fckeditor/fckeditor.php") ;?>
<?php @ require_once("header.php"); ?>
<title>Edit Pages</title>
</head>
<body>
<div id="main">
<form action="editor.php" method="post">
<?php
// Get data from the database
$query = mysql_query("SELECT * FROM instructions WHERE id = 1");
$data = mysql_fetch_array($query);
// Configure and output editor
$oFCKeditor = new FCKeditor('fcktext');
$oFCKeditor->BasePath = '[URL unfurl="true"]http://localhost/garynewport/designs/fckeditor/';[/URL]
$oFCKeditor->Value = $data["details"];
$oFCKeditor->Height = 400;
$oFCKeditor->Create() ;
?>
<br>
<input type="hidden" name="submit_form" value="1" />
<input type="submit" value="Save Form" />
</form>
</div>
<?php
mysql_close($cnx);
?>
</body>
</html>
Anyone able to help?