Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why is the quantity not saving when i run my save.php . Whenever i submit or press enter it doesn't submit to the database. prepare
Why is the quantity not saving when i run my save.php Whenever i submit or press enter it doesn't submit to the database.
prepareSELECT userid branch FROM users WHERE username ;
$userQuerybindparams $username;
$userQueryexecute;
$userResult $userQuerygetresult;
$userRow $userResultfetchassoc;
$userId $userRowuserid;
$userBranch $userRowbranch;
$userLevel $SESSIONlevel; Fetch user level from session
foreach $ids as $id
$sizes $POSTsize$id;
$sizesString implode $sizes;
$quantity $POSTquantity$id;
$branch $userBranch; Use the branch from the user info
if $userLevel $userLevel
Update only the quantity
$orderStmt $connprepare
INSERT INTO orderbranch userid itemid quantity, size
VALUES
ON DUPLICATE KEY UPDATE
quantity VALUESquantity
;
elseif $userLevel
Update only the size
$orderStmt $connprepare
INSERT INTO orderbranch userid itemid quantity, size
VALUES
ON DUPLICATE KEY UPDATE
size VALUESsize
;
else
If user level is not or skip the operation
continue;
$orderStmtbindparamsiiis $branch, $userId, $id $quantity, $sizesString;
$orderStmtexecute;
headerLocation: order.php;
exit;
else
headerLocation: order.php;
exit;
Note: The was manually inputted through mysqltableDayMeal Type,Type,Item,Size,Color,Site,QuantityMondayLunch,Fried,Fried German Franks,Small,Large,XLBrown,On Site,MondayBreakfast,Fried,Hungarian Sausage,Small No Fry,Medium No Fry,Large,Brown,On Site,MondayBreakfast,Fried,Fried Luncheon Meat,Small,Brown,On Site,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started