I'm building a site where the I can add and edit the products that are in mysql. I am trying to add a dynamic product id for each "delete" link. So instead of having a hard code of :
<a href ="delete.php?item=19">Delete</a>, it would be:
<a href="delete.php?item=$product_id>Delete</a>.
What is the code I need just to find the product id for each row and put it into the page. Here's my code so far:
<html>
<head></head>
<body>
<?php $global_dbh =mysql_connect("sql database","username","Password");
mysql_select_db("table name", $global_dbh);
$query_product ="select * from Product";
$result_id=mysql_query($query_product);
$column_count = mysql_num_fields($result_id);
echo("<TABLE BORDER=1>\n");
echo ("<TR ALIGN=LEFT VALIGN=TOP>");
echo ("<TD> Product Id</TD>\n");
echo ("<TD>Description</TD>\n");
echo ("<TD>Photo</TD>\n");
echo ("<TD>Product</TD>\n");
echo ("<TD></TD>\n");
echo ("<TD> Description</TD>\n");
echo ("</TR>");
while ($row = mysql_fetch_row($result_id))
{
echo ("<TR ALIGN=LEFT VALIGN=TOP>");
for ($column_num = 0;
$column_num < $column_count;
$column_num++)
echo ("<TD> $row[$column_num]</TD>\n");
echo ("<TD>edit</TD>\n");
echo ("<TD><a href=delete.php?item=$id2>delete</a></TD>\n");
echo ("</TR>\n");
}
echo("</TABLE>\n");
?>
</body>
</html>
Thanks for all the help!