Question: 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
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
