isaiaha
03-27-2009, 05:45 PM
Hi
Thank you for any suggestions. Trying to know whether a checkbox is selected or not. would like a 0/1 value in each column in db as relates to each checkbox?
Example of how we'd like it to work
week1 - not selected
week2 - selected
week3 - selected
week4 - not selected
MYSQL DB
id --- w1 --- w2 --- w3 --- w4
1 ----- 0 ---- 1 ----- 1 ----- 0
however here is my code and it does create one row in the database and the correct implode values do appears based on what was selected (week2, week3) - however I don't know how to run through each of checkboxes and put a 0 in the ones that weren't selected and 1 in those that were selected instead of their value.
what's happening in my db
id --- w1 ---- w2 ----- w3 ---- w4
1 ---- (w2) -- (w3)
then obviously get the error that the column amt doesn't match. - I have the values inserting... however would like just a 0 for not selected and 1 for selected!
$summer_weeks = $_POST['summer_camp'];
$query = 'INSERT INTO userweeks (week_id, w1, w2, w3, w4, w5, w6) VALUES (NULL, ';
$add = "'".implode("','",$summer_weeks)."'";
for($i = 0; $i > $count; $i++) {
$add .= ",NULL";
}
$query .= $add.')';
*/
$result = @mysql_query ($query);
Thank you for any suggestions
Thank you for any suggestions. Trying to know whether a checkbox is selected or not. would like a 0/1 value in each column in db as relates to each checkbox?
Example of how we'd like it to work
week1 - not selected
week2 - selected
week3 - selected
week4 - not selected
MYSQL DB
id --- w1 --- w2 --- w3 --- w4
1 ----- 0 ---- 1 ----- 1 ----- 0
however here is my code and it does create one row in the database and the correct implode values do appears based on what was selected (week2, week3) - however I don't know how to run through each of checkboxes and put a 0 in the ones that weren't selected and 1 in those that were selected instead of their value.
what's happening in my db
id --- w1 ---- w2 ----- w3 ---- w4
1 ---- (w2) -- (w3)
then obviously get the error that the column amt doesn't match. - I have the values inserting... however would like just a 0 for not selected and 1 for selected!
$summer_weeks = $_POST['summer_camp'];
$query = 'INSERT INTO userweeks (week_id, w1, w2, w3, w4, w5, w6) VALUES (NULL, ';
$add = "'".implode("','",$summer_weeks)."'";
for($i = 0; $i > $count; $i++) {
$add .= ",NULL";
}
$query .= $add.')';
*/
$result = @mysql_query ($query);
Thank you for any suggestions