supanoob Posted April 29, 2010 Share Posted April 29, 2010 Basically, what i want to do is update numerous database fields, if the checkbox linked to their ID is checked. if that makese sense? I will have a page where multiple items will be shown, with a checkbox linked to them using a unique (auto_inc) ID, i then want to be able to select numerous items using the check box, and hit a validate button. I then want all the checked items to update in the database, i want the verified field to go from 0 to 1. Link to comment https://forums.phpfreaks.com/topic/200194-check-boxes-loops-and-databases/ Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 Thanks for sharing your thoughts. But please only post in this forum if you have a PHP-related coding problem. Link to comment https://forums.phpfreaks.com/topic/200194-check-boxes-loops-and-databases/#findComment-1050636 Share on other sites More sharing options...
jdavidbakr Posted April 29, 2010 Share Posted April 29, 2010 Something like this? The fields in the form (method=post): <input type="checkbox" name="user[]" value="1"> <input type="checkbox" name="user[]" value="2"> The php code to identify which users were checked: if (is_array($_POST['user'])) { foreach($_POST['user'] as $id) { // $id contains the value of each checked box, process as you wish } } Link to comment https://forums.phpfreaks.com/topic/200194-check-boxes-loops-and-databases/#findComment-1050640 Share on other sites More sharing options...
supanoob Posted April 29, 2010 Author Share Posted April 29, 2010 Thanks for sharing your thoughts. But please only post in this forum if you have a PHP-related coding problem. is this not php related? did i not ask for php help? Something like this? The fields in the form (method=post): <input type="checkbox" name="user[]" value="1"> <input type="checkbox" name="user[]" value="2"> The php code to identify which users were checked: if (is_array($_POST['user'])) { foreach($_POST['user'] as $id) { // $id contains the value of each checked box, process as you wish } } Thanks for ya help i will try that Link to comment https://forums.phpfreaks.com/topic/200194-check-boxes-loops-and-databases/#findComment-1050654 Share on other sites More sharing options...
Ken2k7 Posted April 29, 2010 Share Posted April 29, 2010 Thanks for sharing your thoughts. But please only post in this forum if you have a PHP-related coding problem. is this not php related? did i not ask for php help? You didn't ask for anything, other than if your request made sense. Other than that, you only told me what you wanted to do. You didn't ask a question related to PHP or specify what help you need help with. I mean, was there a problem with your code? Is it a logical issue and you don't know where to start? Link to comment https://forums.phpfreaks.com/topic/200194-check-boxes-loops-and-databases/#findComment-1050664 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.