francoisp Posted April 28, 2003 Share Posted April 28, 2003 The problem is that I want to populate a select box then the user selects value and submit this to db. The problem however is that the select box\'s value is not passed. The values do appear but the selected valus is not passed. Where am i making the mistake or where can I get the correct code to do this ? Thanks This file submits to file2(addtodb.php) <? include \'db.php\'; $results2= mysql_query("SELECT * from product Group by make asc"); $idmake = "makeid"; $iddescription = "description"; $idnamemake = "make"; echo mysql_error(); ?> <form method=POST action=addtodb.php> <? echo" <select name=\'make\'>"; //start the select box if (mysql_Numrows($results2)>0) //if there are records in the fields { $numrows=mysql_NumRows($results2); //count them $x=0; while ($x<$numrows){ //loop through the records $theId=mysql_result($results2,$x,$idmake); //place each record in the variable everytime we loop $theName=mysql_result($results2,$x,$idnamemake); echo "<option value=\'$idnamemake\'>$theName</option>n"; //and place it in the select $x++; } } echo "</select>"; //close the select ?> <p align=center><font face=Verdana size=1><input type=submit value=Submit name=B1><input type=reset value=Reset name=B2></font></p> </form> Quote Link to comment Share on other sites More sharing options...
shivabharat Posted April 28, 2003 Share Posted April 28, 2003 $results2= mysql_query("SELECT * from product Group by make asc"); while ($row = mysql_fetch_assoc($result2)) { $opt_value = $row[\'row u want\']; $opt_name = $row[\'row u want\']; $option = "<OPTION VALUE=\'" . $opt_value . "\'>" . $opt_name . "</OPTION>n"; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.