delete multiple rows using checkbox forms

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
new to php
Forum Newbie
Posts: 11
Joined: Fri Nov 29, 2002 6:16 am

delete multiple rows using checkbox forms

Post by new to php »

can you delete multiple rows using checkbox forms?
If so how, help please Im new to PHP.

thanks
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I tried to explain it here: viewtopic.php?t=4396
Maybe you find it helpful.
In short: If you have a form like

Code: Select all

<form method="POST" ... >
	<input type="checkbox" name="todeleteї]" value="45" />record id 45<br/>
	<input type="checkbox" name="todeleteї]" value="46" />record id 46<br/>
	<input type="checkbox" name="todeleteї]" value="50" />record id 50<br/>
	<input type="checkbox" name="todeleteї]" value="55" />record id 55<br/>
	<input type="checkbox" name="todeleteї]" value="78" />record id 78<br/>
	<input type="submit" />
</form>
and it is sumbmitted to your php-script $_POST['todelete'] will be an array containing the values of all checked elements (and only of the checked elements).
You can iterate this array e.g. via

Code: Select all

foreach($_POSTї'todelete'] as $id)
	myDeleteRecordById($id); // what ever this function does
Post Reply