Jump to content


Photo

Select Fill from DB then change posted back to DB


  • Please log in to reply
1 reply to this topic

#1 francoisp

francoisp
  • Members
  • Pip
  • Newbie
  • 4 posts
  • LocationSouth Africa

Posted 28 April 2003 - 10:23 AM

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>



#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 28 April 2003 - 03:25 PM

$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";







 }

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users