I need to send the values of two arrays to a function to add them to the MySQL database. The customer id column in MySQL remains as '0'. Could anyone tell me why this is, here is the code I'm using:
if($add)
{
if($ShoppingCart)
$session = $ShoppingCart;
$result = mysql_query( "SELECT * FROM inventory WHERE product='$add'");
$row = mysql_fetch_array($result);
$result2 = mysql_query("select cust_id from customer where name='$cust_name'");
$row2 = mysql_fetch_array($result2);
$cart->add_item($table,$session,$row[product],1,$row[price],$row2[cust_id]);
}
function add_item($table,$session,$product,$quantity,$cost_price,$cust_id)
{
if($num_rows == 0)
{
$sql = "INSERT INTO $table (session,product,quantity,cost_price,cust_id) VALUES ";
$sql .= "('$session','$product','$quantity','$cost_price','$cust_id')";
mysql_query( "$sql");
}
Any ideas why customer id remains at '0'???????