Jump to content

Archived

This topic is now archived and is closed to further replies.

francoisp

Select Fill from DB then change posted back to DB

Recommended Posts

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 ? :cry:

 

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>

Share this post


Link to post
Share on other sites
$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";



}

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.