sylunt1 Posted January 23, 2008 Share Posted January 23, 2008 I have a form that prints out a list of tasks with a checkbox that the user marks when it is complete. Basically its like this: task 1 task desctiption []done task 2 task desctiption []done ... task 100 task desctiption []done Each task has a unique task_id but I am confused how to enter this in the db. I want to be able to take the task_ids that have the check (value of 1) and update the db with this. Example Tasks 1, 5, 12,and 17 have a check so where task_id=1 and task_id=5 (etc...) update field to a 1. I am just not sure how to get here... Thanks. Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/ Share on other sites More sharing options...
teng84 Posted January 23, 2008 Share Posted January 23, 2008 if you set up your chk box like this name = "somename[]"//as array then you can do something like this where id IN(implode(",",$_POST['somename'])) Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/#findComment-447301 Share on other sites More sharing options...
sylunt1 Posted January 23, 2008 Author Share Posted January 23, 2008 Here is how I list out the tasks... if ($tasks_id != $previous_tasks_id){ print '<table width="90%" cellspacing="3" cellpadding="3" border="0"><tr><td width="30%" height="1">' . $tasks_id . ' - ' . $tasks_task . '</td><td halign="left" width="30%" height="1"><INPUT TYPE=CHECKBOX NAME="' . $tasks_id . '"" VALUE="1""> complete</td></tr></table>'; $previous_tasks_id = $tasks_id ; } Will this need to be modified as well? Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/#findComment-447310 Share on other sites More sharing options...
teng84 Posted January 23, 2008 Share Posted January 23, 2008 if ($tasks_id != $previous_tasks_id){ print '<table width="90%" cellspacing="3" cellpadding="3" border="0"> <tr> <td width="30%" height="1">' . $tasks_id . ' - ' . $tasks_task . '</td> <td halign="left" width="30%" height="1"> <INPUT TYPE="CHECKBOX" NAME="taskid[]" VALUE="'.$tasks_id.'"> complete </td> </tr> </table>'; $previous_tasks_id = $tasks_id ; } //then maybe you will need to do something like where id IN(implode(",",$_POST['taskid'])) this? Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/#findComment-447313 Share on other sites More sharing options...
sylunt1 Posted January 23, 2008 Author Share Posted January 23, 2008 Then on the page where the processing happens - how do I go about setting that part up to grab it? Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/#findComment-447323 Share on other sites More sharing options...
teng84 Posted January 23, 2008 Share Posted January 23, 2008 this will be a part of your query where id IN(implode(",",$_POST['taskid'])) it grabs the data form your chk boxes and get the data from the db whee id in you're chk that is checked Link to comment https://forums.phpfreaks.com/topic/87456-submitting-multiple-items-on-a-form/#findComment-447343 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.