Here is my problem:
<?php
/* Connecting, selecting database */
$link = mysql_connect("localhost", "", "")
or die("Could not connect");
mysql_select_db("shopping") or die("Could not select database");
/* Performing SQL query */
$query = "SELECT * FROM cart";
$result = mysql_query($query) or die("Query failed");
/* Printing results in HTML */
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\"
cellpadding=\"3\">\n<tr>
<td colspan=\"6\"><b>Select item(s) for
purchase</b></td>
</tr><tr>
<td width=\"3%\"
bgcolor=\"#e4e4e4\"><u>ID</u></td>
<td width=\"10%\"
bgcolor=\"#e4e4e4\"><u>Name</u></td>
<td width=\"15%\"
bgcolor=\"#e4e4e4\"><u>Item Number</u></td>
<td width=\"18%\"
bgcolor=\"#e4e4e4\"><u>Description</u></td>
<td width=\"3%\"
bgcolor=\"#e4e4e4\"><u>Cost</u></td>
<td width=\"3%\" bgcolor=\"#e4e4e4\"><u>Sale</u></td>
<td width=\"8%\" bgcolor=\"#e4e4e4\"><u>Add Item</u></td>
</tr>";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "<td width=\"10%\"> <form name=\"add_item\" method=\"post\"
action=\"add_item\">
</form>
<input type=\"text\" name=\"add_num\"
size=\"3\" maxlength=\"6\">
<input type=\"submit\" name=\"add\"
value=\"add\"></form>
</td>\t</tr>\n";
}
print "</table>\n";
/* Free resultset */
mysql_free_result($result);
/* Closing connection */
mysql_close($link);
?>
I use this to query the database and put the results into a form for later
use... The problem I am having is how would I assign a unique field name for
each entry displayed? I am not sure how I can do this with the $col_value
simply echoing the results onto the page, if anyone could shed some light on
this I would appreciate it. Thanks in advance,
Jas
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php