Answered step by step
Verified Expert Solution
Question
1 Approved Answer
How do i make it that when i click on a checkbox it saves it automatically into the database when the save button is pressed.
How do i make it that when i click on a checkbox it saves it automatically into the database when the save button is pressed. It should save in the way as displayed in the screenshot of the database shown. Currently, all i can do is manually type it in the database and it reflects on the checkboxes on the order page.
save.php
query$sql;
if $resultnumrows
$row $resultfetchassoc;
else
echo No record found.";
exit;
if isset$POSTsaveButton
if isset$POSTsizes
$sizes $POSTsizes;
$sizeString implode $sizes;
$query "UPDATE testdatabase SET size$sizeString' WHERE id $id;
$run mysqliquery$conn, $query;
if $run
headerLocation: orders.php;
exit;
else
echo "Error updating record: $connerror;
else
echo No size selected.";
else
echo "Invalid request.";
exit;
ordertable:
Fetch and display the results
while$row $resultfetchassoc
$sizes explode $rowsize;
$sizeChecked function$size use $sizes
return inarray$size, $sizes 'checked' : ;
;
echo
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