Hey guys I'm pretty new to this and I'm having a little trouble. I am writing an update page and querying 2 different fields in the DB. One is Price but if nothing is entered in the price field I don't want it to change from the original price that was entered(if that makes any sense at all! ) Here is the code I am writing if someone could look at it and tell me where I'm going wrong it would be greatly appreciated. Remeber I'm new at this so don't laugh too much when you look at it.
Thanks. PS someone told me to wrap the the sql statement into an if statement to make this work...Am I putting it in the wrong place? I am at my wits end!
<?php
// begin content
include("inc/nav.php");
// create short variable names
$partno=$POST['partno'];
$price=$POST['price'];
$quantity=$_POST['quantity'];
if (!$partno || !$quantity)
{
echo 'You have not entered PART NUMBER or QUANTITY.<br />Please go back and try again.';
exit;
}
if (!get_magic_quotes_gpc())
{
$partno = addslashes($partno);
$price = addslashes($price);
$quantity = addslashes($quantity);
}
include("inc/connect.php");
if (!empty($price))
{
$queryA= "update products set price = '".$price."'
where item = '".$partno."';";
$resultA= mysql_query("$queryA");
}
$query = "update products set quantity = '".$quantity."' where item = '".$partno."';";
$result = mysql_query("$query");
if ($result)
echo mysql_affected_rows($result).' Item Updated.';
else echo (mysql_error());
?>
</body>
</html>