hi ,
i wrote a code for to delete the particular rows in a table using check boxes.But in that i select the particular rows and click on the delete button these rows didn't delete.plz check it what's the problem in that code.
<?php
$host="localhos t"; // Host name
$username="root "; // Mysql username
$password=" "; // Mysql password
$db_name=" db1"; // Database name
$tbl_name="test _mysql"; // Table name
// Connect to server and select databse.
mysql_connect(" $host", "$username" , "$password" )or die("cannot connect");
mysql_select_db ("$db_name") or die("cannot select DB");
$sql="SELECT * FROM $tbl_name";
$result=mysql_q uery($sql);
$count=mysql_nu m_rows($result) ;
?>
<table width="400" border="0" cellspacing="1" cellpadding="0" >
<tr>
<td><form name="form1" method="post" action="">
<table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCC C">
<tr>
<td bgcolor="#FFFFF F"> </td>
<td colspan="4" bgcolor="#FFFFF F"><strong>Dele te multiple rows in mysql</strong> </td>
</tr>
<tr>
<td align="center" bgcolor="#FFFFF F">#</td>
<td align="center" bgcolor="#FFFFF F"><strong>I d</strong></td>
<td align="center" bgcolor="#FFFFF F"><strong>Name </strong></td>
<td align="center" bgcolor="#FFFFF F"><strong>Last name</strong></td>
<td align="center" bgcolor="#FFFFF F"><strong>Emai l</strong></td>
</tr>
<?php
while($rows=mys ql_fetch_array( $result)){
?>
<tr>
<td align="center" bgcolor="#FFFFF F"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $rows['id']; ?>"></td>
<td bgcolor="#FFFFF F"><?php echo $rows['id']; ?></td>
<td bgcolor="#FFFFF F"><?php echo $rows['name']; ?></td>
<td bgcolor="#FFFFF F"><?php echo $rows['lastname']; ?></td>
<td bgcolor="#FFFFF F"><?php echo $rows['email']; ?></td>
</tr>
<?php
}
?>
<tr>
<td colspan="5" align="center" bgcolor="#FFFFF F"><input name="delete" type="submit" id="delete" value="Delete"> </td>
</tr>
<?php
echo "hello";
// Check if delete button active, start this
if($delete) {
echo "hello";
for($i=0;$i<$co unt;$i++){
$del_id = $checkbox[$i];
echo "$del_id";
echo "hello";
$sql = "DELETE FROM $tbl_name WHERE id='$del_id'";
$result = mysql_query($sq l);
}
// if successful redirect to delete_multiple .php
if($result){
echo "<meta http-equiv=\"refresh \" content=\"0;URL =checkk.php\">" ;
}
}
mysql_close();
?>
</table>
</form>
</td>
</tr>
</table>