j3rmain3 Posted November 24, 2006 Share Posted November 24, 2006 I have built a form to populate the DB. The DB has data in it but form also has dropdown menus on each row so the user can add a rating to whether the document is good or not. i am confused on how to link the position of the rating to the position in the table. I was thinkin of doing a rate_id and link it to the dropdown menu which is being altered and the match it with the document id, but i do not know how to place a id to a dropdown menu bcz i do not know how a dropdown can be placed in the DB. Can anyone help? Here is the coding for the form and table.form[code]<html><head><title>Dropdown Menu</title><head><body><?php $host = "localhost";$user = "root";$pass = "mysql";$db = "test";$connection = mysql_connect($host,$user,$pass) or die ("ERROR:Unable to connect".mysql_error());mysql_select_db($db) or die ("ERROR: Unable to connect to DB".mysql_error());$query = "SELECT * FROM menu";$result = mysql_query($query) or die ("ERROR:Unable to run query".mysql_error());if (mysql_fetch_row($result) > 0){ echo "<form action=formprocess4.php method=POST name=rating>"; echo "<table border=1 cellpadding=3 cellspacing=3>"; echo "<tr>"; echo "<td><font face=Verdana size=-1><b>ID</td>"; echo "<td><font face=Verdana size=-1><b>Document Title</td>"; echo "<td><font face=Verdana size=-1><b>Rating</b></td>"; echo "</tr>"; while ($row=mysql_fetch_assoc($result)) { echo "<tr>"; echo "<td><font face=Verdana size=-1>".$row['id']."</td>"; echo "<td><font face=Verdana size=-1>".$row['doc']."</td>"; echo "<td><select name=rates><option value= SELECTED><option value=1 name=$row[doc]rw>1 - Poor<option value=2 name=$row[doc]rw>2 - Average<option value=3 name=$row[doc]rw>3 - Excellent</select>"; echo "</td>"; echo "</tr>"; }echo "</table>";echo "<br>";echo "<input type=submit name=submit value=submit>";echo "</form>";}echo "<a href=http://localhost/brainstorm/phpFreaks/entryform.php><font face=Verdana size=-1>Back To Form</a>";?></body></html>[/code]table[code]<html><head><title>Dropdown Menu</title><head><body><?php $host = "localhost";$user = "root";$pass = "mysql";$db = "test";$connection = mysql_connect($host,$user,$pass) or die ("ERROR:Unable to connect".mysql_error());mysql_select_db($db) or die ("ERROR:Unable to connect to DB".mysql_error());$query = "SELECT * FROM menu";$result = mysql_query($query) or die ("ERROR:Unable to run query".mysql_error());$update_table = "UPDATE menu SET rating=$_POST['rating'] WHERE /*while ($row=mysql_fetch_assoc($result)){ $*/echo "<h3><font face=Verdana>Table</h3>";if (mysql_fetch_row($result) > 0 ){ echo "<table border=1 cellpadding=3 cellspacing=3>"; echo "<tr>"; echo "<td><font face=Verdana size=-1>Document Title</td></font>"; echo "<td><font face=Verdana size=-1>Rating</td></font>"; while ($row=mysql_fetch_assoc($result)){ echo "<tr>"; echo "<td><font face=Verdana size=-1>".$row['doc']."</td>"; echo "<td><font face=Verdana size=-1>".$row['rating']."</td>"; echo"</tr>"; } echo "</table>";}echo "<br><a href=http://localhost/brainstorm/phpFreaks/entryform.php><font face=Verdana size=-1>Back To Form</a><br></font>";?></body></html>[/code]thanksJ3rmain3 Link to comment https://forums.phpfreaks.com/topic/28344-adding-data-to-db/ Share on other sites More sharing options...
j3rmain3 Posted November 27, 2006 Author Share Posted November 27, 2006 Anyone know how i can do the above?? ??? Link to comment https://forums.phpfreaks.com/topic/28344-adding-data-to-db/#findComment-130915 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.