Page 1 of 1

delete multiple rows using checkbox forms

Posted: Sun Dec 01, 2002 6:38 pm
by new to php
can you delete multiple rows using checkbox forms?
If so how, help please Im new to PHP.

thanks

Posted: Sun Dec 01, 2002 6:56 pm
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