Unique Field for text field...

From: Date: Sat, 20 Apr 2002 05:50:40 +0000
Subject: Unique Field for text field...
Groups: php.db 
Request: Send a blank email to php-db+get-18699@lists.php.net to get a copy of this message
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

« previous php.db (#18699) next »