How to delete row if checked
Posted: Mon Sep 01, 2008 1:53 am
Hi there, good day. Does anyone know how to delete row if the checkbox in html form is checked, as well as delete the data in the database.
here is my code for creating checkbox and every element in my page:
What will be the right code so that i'll be able to delete those rows which i have checked?
Any help is much appreciated. Thanks
here is my code for creating checkbox and every element in my page:
Code: Select all
<?php
$query = 'Select * from tbl_ingredient';
$result = mysql_query($query) or die('Error in Query');
if(mysql_num_rows($result)>0){
while($row = mysql_fetch_row($result)){
echo "<table width=\"720\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"gridData\" onMouseOver=\"this.style.backgroundColor='#EDE6D4'\"; onMouseOut=\"this.style.backgroundColor='transparent'\">";
echo "<tr align = \"center\" class=\"gridRow\">";
echo "<td width = \"70\"><input type=\"checkbox\" name=\"removeid[]\" id=\"checkbox\" /></td>";
echo "<td width = \"105\">".$row[1]."</td>";
echo "<td width = \"202\">".$row[2]."</br></td>";
echo "<td width = \"140\">".$row[4]."</br></td>";
echo "<td width = \"153\">".$row[3]."</br></td>";
echo "<td width = \"59\"><input name=\"Reset\" type=\"submit\" class=\"gridButtons\" id=\"button\" value=\"Edit\" onmouseover=\"this.style.color = '#000000'\" onmouseout=\"this.style.color = '#666666'\"/></td>";
//echo $row[2]." </br>";
echo "</tr>";
echo "</table>";
}
}
else{
echo 'No rows found';
}?>Any help is much appreciated. Thanks