Jump to content

Select Fill from DB then change posted back to DB


francoisp

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>

Link to comment
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";



}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.