geotri314 Posted July 26, 2010 Share Posted July 26, 2010 Hello guys. I actually have a question about a small text from a book, i use to read so as to learn php. i have come with something i really dont understand. I dont know if i should be asking you this, since my question is more about learning php, than actually writing php, but i have no one else... Ok, so the book gives this code: echo '<input type="checkbox" value="' . $row['id'] . '" name="todelete[]">'; and says this: The square brackets result in the creation of an array within $_POST that stores the contents of the value attribute of every checked checkbox in the form My question is: how is this happening? i mean do i miss some html piece of info where value is assigned to the name of an input? This explanation along with this code is really frustrating. i dont really understand either what it means, or how it does this. Can anyone shed some light please? thank you for your time. Link to comment https://forums.phpfreaks.com/topic/208912-help-with-a-book/ Share on other sites More sharing options...
Mchl Posted July 26, 2010 Share Posted July 26, 2010 It's about this piece of code name="todelete[]" It means that if you create several checkboxes like that (this code is probably in a loop, isn't it?), you will then be able to use $_POST['todelete'] as an array, to see which id's have checkboxes ticked or not. do something like this to see contents of $_POST['todelete'] array var_dump($_POST['todelete']); This is a bit of a magic that HTML/PHP does for you. Link to comment https://forums.phpfreaks.com/topic/208912-help-with-a-book/#findComment-1091245 Share on other sites More sharing options...
geotri314 Posted July 27, 2010 Author Share Posted July 27, 2010 ok thank you, i think i got it after the var_dumo thing. thanks alot Mchl Link to comment https://forums.phpfreaks.com/topic/208912-help-with-a-book/#findComment-1091605 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.