The following code reads in 'id' from another page and conducts a query based on 'id', it should display the id, title and first_name fields from the db and the user should have the option to highlight the text, delete it and enter new text , then click on submit and update the db however that doesn't happen. At the moment the the code below renders on the page but all the fields are blank when they should have the current value in them. I was pretty sure that by putting value="<?=$first_name;?>" into the input box that it would display its current value but it doesn't. any ideas?
<?php
include 'db.php';
if(isset($_GET['id']))
{
$query = "SELECT id, title, first_name FROM tblAccounts WHERE id = '{$_GET['id']}'";
$result = mysql_query($query) or die('Error : ' . mysql_error());
list($id, $title, $content) = mysql_fetch_array($result, MYSQL_NUM);
$content = htmlspecialchars($content);
}
else if(isset($_POST['title']))
{
$id = $_POST['id'];
$title = $_POST['title'];
$first_name = $_POST['first_name'];
if(!get_magic_quotes_gpc())
{
$id = addslashes($id);
$title = addslashes($title);
}
// update the article in the database
$query = "UPDATE tblAccounts SET title ='$title', first_name = '$first_name' WHERE id = '$id'";
mysql_query($query) or die('Error : ' . mysql_error());
echo "<p align='center'>Article updated</p>";
$id = stripslashes($id);
$first_name = stripslashes($first_name);
}
?>
<form method="post" action="cms-edit.php">
<input name="id" type="text" class="box" id="id" value="<?=$id;?>">
<input name="title" type="text" class="box" id="title" value="<?=$title;?>">
<input name="first_name" type="text" class="box" id="first_name" value="<?=$first_name;?>">
<input name="update" type="submit" id="update" value="Update">
</form