
December 9th, 2003, 05:44 PM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 22,309
Time spent in forums: < 1 sec
Reputation Power: 24
|
|
|
adding delete and edit buttons to data gathered from MySql
just like in phpadmin
here is my code
Code:
<?PHP
$db = mysql_connect("localhost","root","") or die("Problem connecting");
mysql_select_db("VC") or die("Problem selecting database");
$query = "SELECT * FROM inventory ORDER BY prod_code";
$result = mysql_query($query) or die ("Query failed");
$numofrows = mysql_num_rows($result);
echo "<TABLE BORDER="0">n";
echo "<TR bgcolor="lightblue"><TD>ID</TD><TD>Name</TD>
<TD>Description</TD><TD>Retail Price</TD><TD>Wholesale Price</TD><TD>Quanity</TD><TD></TD><TD></TD></TR>n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result);
if($i % 2) {
echo "<TR bgcolor="lightgrey">n";
} else {
echo "<TR bgcolor="white">n";
}
echo "<TD>".$row['prod_code']."</TD><TD>".$row['prod_name']."</TD><TD>".$row['prod_description']."</TD>
<TD>".$row['price_retail']."</TD><TD>".$row['price_whole']."</TD><TD>".$row['quanity']."</TD><TD></TD><TD></TD>n";
echo "</TR>n";
}
echo "</TABLE>n";
?>
i added two columns for the edit and delete buttons
i see that you have to use the "DELETE FROM table WHERE field = 'xxx'" in order to accomplish the deletetion of a row of data. now how do i tell it to delete the row that the delete button exists on? is it something like
DELETE FROM inventory WHERE prod_id = '$row['prod_id']'
i cant get this right for nothing
thanks in advance
|