Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete all checked 2

Status
Not open for further replies.

farley99

MIS
Feb 12, 2003
413
US
Hi,

I have a php program that list all my users from a mysql database.

I want to have a check box by each and have the option to delete checked users.

(similar to how you can delete emails on hotmail and yahoo)

How can i do that?
 
For starters, you generate the checkboxes as you generate the list, naming each one in turn with a key that ties it to the list item. Off the top of my head, I'm guessing that your members table lists member name, and that you also have a unique member id number. As the php generates the list have it generate the boxes, and name each box the corresponding id number. Once you have checked the names you want, you send the form to a script that will put the checked box names into an array that you can use to run your delete query. Remember, check boxes are not all one element the way that radio buttons are. Each box is it's own form element and will return a true or false on it's own.
 
make ur checkboxes named as array and pass the id if u have it as unique number or whatever field u have defined unique in ur table structure.
then using which index is checked run the delete query in ur php script..


ie
<!--- html --->
<form..>
<input type=checkbox name=del_email[] value=1>Email1
<input type=checkbox name=del_email[] value=2>Email2
...
</form>

//php script
<?
for($i=0;$i<sizeof($del_email);$i++) {
$sql = &quot;delete from tablename where id=$del_email[$i]&quot;;
...
}
?>

spookie


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top