yolop Posted July 21, 2008 Share Posted July 21, 2008 <?php if(isset($_POST['submit'])) { //here i want to write all the checkbox that choose } ?> <form action='2.php' method='post'> <input type="checkbox" name="check" value='1'> <br> <input type="checkbox" name="check" value='2'><br> <input type="checkbox" name="check" value='3'><br> <input type="checkbox" name="check" value='4'><br> <input type="checkbox" name="check" value='5'><br> <br><input type='submit'name='submit' value='שלח'> </form> how i do that?? if I check one by one it's not good because in the real code I have over of 100 checkbox so...is there a way to write all checkbox that choose?? thank. Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/ Share on other sites More sharing options...
jesushax Posted July 21, 2008 Share Posted July 21, 2008 give the checboxes differrent names then $checkbox1 = $_POST["checkbox1"]; $checkbox2 = $_POST["checkbox2"]; and so on Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595362 Share on other sites More sharing options...
ignace Posted July 21, 2008 Share Posted July 21, 2008 or just write <input type="checkbox" name="check[]" value="1" /> in php you could access it in this manner: <?php echo $_POST['check'][0]; // 1 ?> Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595363 Share on other sites More sharing options...
yolop Posted July 21, 2008 Author Share Posted July 21, 2008 give the checboxes differrent names then $checkbox1 = $_POST["checkbox1"]; $checkbox2 = $_POST["checkbox2"]; and so on ok it's impassable to run "for" and do something like that.. for(I=0;I<100;I++) { $checkbox = $_POST["checkbox "I" "]; } /////here I creat array and put what I got from the form the problem is how I do that $_POST["checkbox "I" "]; thank Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595366 Share on other sites More sharing options...
yolop Posted July 21, 2008 Author Share Posted July 21, 2008 or just write <input type="checkbox" name="check[]" value="1" /> in php you could access it in this manner: <?php echo $_POST['check'][0]; // 1 ?> ohhh smart Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595367 Share on other sites More sharing options...
Wolphie Posted July 21, 2008 Share Posted July 21, 2008 or just write <input type="checkbox" name="check[]" value="1" /> in php you could access it in this manner: <?php echo $_POST['check'][0]; // 1 ?> ohhh smart I prefer to use implode(', ', $_POST['check'])); which will turn the array into a string, with the values being separated by comma's. Or you could loop through them using a foreach loop, if you want to automate things a bit. Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595369 Share on other sites More sharing options...
yolop Posted July 21, 2008 Author Share Posted July 21, 2008 or just write <input type="checkbox" name="check[]" value="1" /> in php you could access it in this manner: <?php echo $_POST['check'][0]; // 1 ?> ohhh smart I prefer to use implode(', ', $_POST['check'])); which will turn the array into a string, with the values being separated by comma's. Or you could loop through them using a foreach loop, if you want to automate things a bit. I will be happy if you explain with code what did you tried to say thank Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595375 Share on other sites More sharing options...
yolop Posted July 21, 2008 Author Share Posted July 21, 2008 I tried to do that <?php if (isset($_POST['del])) { echo $_POST['array[0]']; } ?> echo"<br><br><br> <form action='2.php' method='post'> <input type='hidden' name='array[]' value='1'/> <br><input type='submit' name='del' value='ccc'></form>"; but it's not write anything Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595383 Share on other sites More sharing options...
yolop Posted July 21, 2008 Author Share Posted July 21, 2008 kk thank it's solved Quote Link to comment https://forums.phpfreaks.com/topic/115811-help-with-form-with-checkbox/#findComment-595393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.