Jump to content


This topic is now archived and is closed to further replies.


PHP code and checkboxes.

Recommended Posts


I have made a page in which I load a mysql query.
The results from this query load in page and see some results.
In this page I must allow or reject a site.
The results are like this:

ID    Site                              URL                            Email
1    something                      something.com            something@something.com
2    somewhere                    somewhere.com            something@somewhere.com

Ok, now next to email I have one checkbox and at belwo of page two butons one Allow and one Reject.
The problem is how to make it to connect checkboxes with button and all chackboxes which I click and after click allow, allow site and all sites which check reject, reject them.
I haven't got an idea...
I have done it but with another way which allow me to allow and reject one site every time (writhing the id in a textfield and press either allo or reject...) but this way is not very efficient...
Can you please help me?

Share this post

Link to post
Share on other sites
basically, the best way is to handle all your checkboxes as a big array. name them all the same with "[]" after them. for instance, you may have this at the end of each row:
<input type="checkbox" name="row[]" value="$rowID" />

where $rowID is the id of the URL or email you are reviewing. then, when you check all the ones you want and submit the form, the $_POST['row'] variable then holds all of them as an array. you can loop through them all at that point and either accept or reject them. so, let's say you click "reject":
// reject has been clicked
$rows = $_POST['row'];
foreach ($rows as $row) {
  // now you deal with each one individually and reject them:
  // reject $row;

hope this helps

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.