Re: deleting all checked records

From: Date: Wed, 15 Nov 2000 18:05:36 +0000
Subject: Re: deleting all checked records
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25482@lists.php.net to get a copy of this message
N. Sagar Chand wrote:
hello all, I have a page that displays the records of a table with a checkbox for each record. I want to delete all the checked records. The code is working fine if i check one record.But when i check more than one record i am not able to write the code. please help me. I am giving the code i have written. --------------------------------------------------------- <? $db=mysql_connect("localhost","root","idiot"); mysql_select_db("mydb",$db); $result=mysql_query("select * from sagar"); do{ $i++; $x=$myrow["id"]; echo ""; echo $myrow["name"]; } while ($myrow=mysql_fetch_array($result)); ?> ---------------------------- del.php3 ----------------------------------- <? $db=mysql_connect("localhost","root","idiot"); mysql_select_db("mydb",$db); mysql_query("delete from sagar where id='$chk';"); ?> ---------------------
Ack! HTML email. Bah. Nevertheless, since I can't make out all of your code (some didn't make it into the reply), I'm going to take a wild guess and say that you'll need to use an array in conjunction with the checkboxes if you want to have multiple values for a single name (although it /is/ an array, I'm sure you know what I mean). For example: <input type="checkbox" name="authfiles[]" value="8B3921-798F1R3"> <input type="checkbox" name="authfiles[]" value="94273C-008H7YT"> .... Then refer to that as: <?php while(list($i,) = each($authfiles)) { if($authfiles[$i]) {
      /* do something. */
} } ?> That should get you started. -Brian

« previous php.general (#25482) next »