Hello folks,
I can not seem to find out why this code is not being executed properly. Basically, I'd like to edit Records, so I am using forms to retrieve data, make modifications then save them.
<?php
//connection to db
$results = mysql_query("SELECT * FROM crud WHERE id=".$_GET[id]."") or die (mysql_error());
$row = mysql_fetch_assoc($results);
echo "<form action=\"\" method=\"POST\">";
echo "Year: <input type=\"text\" value=".$row['car_year']." name=\"car_year\" /> <br />";
echo "Make: <input type=\"text\" value=".$row['car_make']." name=\"car_make\" /> <br />";
echo "Model: <input type=\"text\" value=".$row['car_model']." name=\"car_model\" /><br /><br />";
echo "Description:<br /><textarea rows=\"15\" cols=\"60\" name=\"description\" />". $row['description']. "</textarea>";
echo "<br /><input type=\"submit\" value=\"save\">";
echo "</form>";
if ($_POST['save']) {
$car_year = $_POST['car_year'];
$car_make = $_POST['car_make'];
$car_model = $_POST['car_model'];
$description = $_POST['description'];
// Update data
$update = mysql_query("UPDATE crud SET car_year='$car_year', car_make='$car_make' car_model='$car_model', description='$description' WHERE id=".$_GET['id']."") or die (mysql_error());
echo 'Update successfull';
}
?>
Please HELP!!!!