Hi guys, forum noob here.
I'm very new to php and i'm trying to build a simple food order shopping cart. I'm using DW as a crutch at the moment just to get a feeling of how php works.
I have a page where a user can select food extras to add to thier food item using checkboxes.
heres the recordset for getting extras.
$colname_rs_addedextras = "1";
if (isset($_GET['idfooditem'])) {
$colname_rs_addedextras = $_GET['idfooditem'];
}
mysql_select_db($database_dbconnect, $dbconnect);
$query_rs_addedextras = sprintf("SELECT extra.idextra, extra.extraName, extra.extraPrice, addedextras.extraFree FROM addedextras, extra WHERE fooditemID = %s AND addedextras.extraID = extra.idextra", GetSQLValueString($colname_rs_addedextras, "int"));
$rs_addedextras = mysql_query($query_rs_addedextras, $dbconnect) or die(mysql_error());
$row_rs_addedextras = mysql_fetch_assoc($rs_addedextras);
$totalRows_rs_addedextras = mysql_num_rows($rs_addedextras);
Here is the code i'm strugling with.
// Submit to Order Form /////////////////////////////
if (isset($_POST["addtoorderButton"]))
{
mysql_query("INSERT INTO cart(cookieID, customerID, fooditemID, foodItemName, foodItemPrice) VALUES('$cookieID', '$customerID', '$fooditemID', '$foodItemName', '$foodItemPrice' ) ") or die(mysql_error());
if ($_POST['checkbox'] != NULL)
{
$cart_id = mysql_insert_id();
foreach($_POST['checkbox'] as $key => $value)
{
$extraPrice = $row_rs_addedextras['extraPrice'];
$extraFree = $row_rs_addedextras['extraFree'];
$extraFree = $row_rs_addedextras['extraFree'];
//echo $key;
mysql_query("INSERT INTO cartextras(cartID, cookieID, extraName, extraID, extraPrice, extraFree) VALUES('$cart_id', '$cookieID', '$extraName', '$key', '$extraPrice', '$extraFree') ") or die(mysql_error());
}
}
}
The code kinda works, I just can't figure out how to add the extraPrice and extraFree also.
Any kind of guidence would be very apprieated as I have been trying to figure this out for a couple of days now, wanted to figure it out by myself because I think to learn faster that way.
If you need anymore of the code pleae let me know.