Search This Blog

Sunday, 4 October 2015

Delete multiple rows from mysql with checkbox in php.

if(isset($_POST['Submit']))

{

foreach($_POST['check'] as $val1)
{
mysql_query("delete from tablename where id=".$val1."");

}

}

?>

<?php

$rec=mysql_query("select * from table name");

while($row=mysql_fetch_array($rec))

{

?>

<input type="checkbox" name="check[]" value="<?php echo $row['id'];?>" />

<?php }?>

<input type="submit" name="Submit" value="Delete" />

No comments:

Post a Comment