Below is the the code where I am trying to to update my food items into the database but am failing to do it, any corrections will be helpful. Thanks in advance
<?php
// set database server access variables:
$host = "localhost";
$user = "root";
$pass = "";
$db = "onlinefs";
// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to
connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
if (isset($_POST['description']))
{
$descript = $_POST['description'];
$price = (double)$_POST['price'];
//$insertQuery = "INSERT INTO foodlist (description)
VALUES ('".$descript."')";
$insertQuery = "description...";
//$insertQuery = "SELECT * foodlist (price) VALUES
('".$price."')";
$insertQuery = "price...";
$result = mysql_query($insertQuery);
}
echo '<strong><br />'.$insertQuery.'</strong><br />';
// create query
$query = "SELECT * FROM foodlist ";
$insertQuery = "price...";
$result = mysql_query($insertQuery);
// execute query
$result = mysql_query($query) or die ("Error in query: $query.
".mysql_error());
// see if any rows were returned
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_row($result)) {
echo "<tr>";
echo "<td>".$row[0]."</td>";
echo "<td>" . $row[1]."</td>";
echo "<td>".$row[2]."</td>";
echo "</tr>";
}
echo "</table>";
}
else {
// no
// print status message
echo "No rows found!";
}
// free result set memory
mysql_free_result($result);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>Admin</title></head>
<body>
<?php
extract($_POST);
if (isset($Add))
mysql_query("INSERT INTO foodlist(description,price)
VALUES ('$description','$price')");
else if (isset($description))
mysql_query("DELETE FROM foodlist WHERE
description=$description");
else if (isset($price))
mysql_query("UPDATE foodlist SET price='$price' WHERE
price=$price");
print("<table border='2'>");
print("<thead><th>description</th><th>price</th></thead>");
print("<tbody>");
if ($result=mysql_query("SELECT * FROM foodlist"))
{
while ($row=mysql_fetch_array($result))
{
extract($row);
print("<tr>");
print("<td>$description</td><td>$price</td></td>");
print("</tr>");
}
}
print("</tbody></table>");
if ($result=mysql_query("SELECT * FROM foodlist"))
{
while ($row=mysql_fetch_array($result))
{
extract($row);
print("<tr>");
print("<td>$price</td>");
print("</tr>");
}
}
print("</tbody></table>");
?>
<form method="post" action="<?=$SERVER["PHP_SELF"]?>
<p> Add Description: <input type="text"
name="description"/></p>
<p>Add price: <input type="text" name="price"/> </p>
</form>
<form method="post" <form method="post"
action="<?=$SERVER["PHP_SELF"]?>
<p>Delete items:<input type="text" name="delete"/>
<p> <input type="submit" name="add" value="Save"/></p>
</form>
</body>
</html>