Hi,
Firstly apologies as i shouldnt have set a previous thread as solved.
The following script should:
1. get record with id of 1 and display in text box
2. after user changes it, it is written to mysql
3. the screen informs user that this has been achieved
<?php
$result = mysql_query("select * from indexinfo where id = 1");
$row = mysql_fetch_assoc($result);
if ( isset( $_POST['send'] ) ) {
// The author's details have been updated.
$title = $_POST['Title'];
$subtitle = $_POST['Subtitle'];
$content = $_POST['Content'];
$author = $_POST['Author'];
$date = $_POST['Date'];
$id = $_POST['id'];
$sql = "UPDATE `indexinfo` SET
`Title` = '$title',
`Subtitle` = '$subtitle',
`Content` = '$content',
`Author` = '$author',
`Date` = '$date'
WHERE `id` = '$id'";
if (mysql_query($sql)) {
echo '<p>Author details updated.</p>';
} else {
echo '<p>Error updating author details: ' .
mysql_error() . '</p>';
}
?>
<form action="#" method="post">
<p>Edit the author:</p>
<label>Title: <input type="text" name="Title" value="<?php echo $title; ?>" /></label><br />
<label>Subtitle: <input type="text" name="Subtitle" value="<?php echo $subtitle; ?>" /></label><br />
<label>Content: <TEXTAREA name="Content" ROWS=10 COLS=100><?php echo $content; ?></TEXTAREA><br />
<label>Author: <input type="text" name="Author" value="<?php echo $author; ?>" /></label><br />
<label>Date: <input type="text" name="Date" value="<?php echo $date; ?>" /></label><br />
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="submit" value="Submit" name="send" /></p>
</form>
<?php
} else {
?>
<form action="#" method="post">
<p>Edit the author:</p>
<label>Title: <input type="text" name="Title" /></label><br />
<label>Subtitle: <input type="text" name="Subtitle" /></label><br />
<label>Content: <TEXTAREA name="Content" ROWS=10 COLS=100></TEXTAREA><br />
<label>Author: <input type="text" name="Author" /></label><br />
<label>Date: <input type="text" name="Date" /></label><br />
<input type="hidden" name="id" />
<input type="submit" value="Submit" name="send" /></p>
</form>
<?php } ?>