item quantity is added to item total the value keeps up increasing
eg 1+1 =2, 2+3 =5 and so on, but if I try to update the table column(item_total),
the new update always replace the old value instead of increasing it and the error below will
be displayed
"Notice: Undefined index: Radio in C:\test\htdocs\product.php on line 32"
below is my effort so fare, any help please
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="root"; // Mysql password
$db_name="test"; // Database name
// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
// Get values from form
$item_id = $_POST['item_id'];
$item_name = $_POST['item_name'];
$item_quantity = $_POST['item_quantity'];
// Insert data into mysql
$sql="INSERT INTO product_bakup(item_id,item_name,item_quantity)VALUES('$item_id','$item_name','$item_quantity')";
$result=mysql_query($sql);
$sql1 = "SELECT item_total FROM product WHERE item_id='$item_id' ";
$res=mysql_query($sql1);
while(!$res){
$row = mysql_fetch_array($res);
$Radio=$row['item_total'];
return $Radio;
}
$add_new = $_POST['Radio'] + $_POST['item_quantity'];
//$newbal=$_POST['bal'];
$sql2 = "UPDATE product SET item_total='$add_new' WHERE item_id='$item_id'";
$result=mysql_query($sql2);
// if successfully updated.
if($result){
echo "Successful";
}
else {
echo "ERROR";
}
// close connection
mysql_close();
?>


Sign In
Create Account


Back to top









