Jump to content

PHP code and checkboxes.


crash21

Recommended Posts

Hello,

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?
Link to comment
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:
[code]
<input type="checkbox" name="row[]" value="$rowID" />
[/code]

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":
[code]
<?php
// reject has been clicked
$rows = $_POST['row'];
foreach ($rows as $row) {
  // now you deal with each one individually and reject them:
  // reject $row;
}
?>
[/code]

hope this helps
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.