delete row from table
Posted: Fri Apr 09, 2004 3:21 am
hi all,
got a little problem again. i'm creating an online shop. when users press the "add product" button, a table is shown with the products they ordered, a shopping cart if u will
next to each row i've placed a delete button so they can delete the products they don't want. when the press the delete button, always the first record in my db table is deleted, not the record they want to delete.
Anyone got an idea when pressing a delete button how to delete the corresponding record?
thx
RuffRyder
got a little problem again. i'm creating an online shop. when users press the "add product" button, a table is shown with the products they ordered, a shopping cart if u will
Code: Select all
//showorder.php
global $conn;
$bestelling = "select * from bestdetl where bnummer = 1";
$result = mysql_query($bestelling,$conn);
print "<form name='form1' method='post' action='dealers.php?p=delete'>";
print "<table width='75%' align='center' cellspacing='0' cellpadding='0' border='1'>\n";
while ($row = mysql_fetch_array($result)){
print "\t<tr onmouseover="selected(this)" onmouseout="deselected(this)" >";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["model"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["breedte"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["lengte"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["type"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["stab"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["cover"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b>" . $row["aantal"] . "</b></font></td>";
print "\t\t<td align='center'><font color='#666666' face='tahoma'><b> <input type='image' src='images/delete.gif' name='$rownr'> </b></font></td>";
print "\t</tr>";
}
print "</table>\n";
print "</form>";
mysql_close($conn);
//delete.php
<?
include("database.php");
global $conn;
$delete = mysql_query('DELETE '.$_POST['$rownr'].' FROM bestdetl LIMIT 1',$conn);
echo "product deleted";
?>thx
RuffRyder