Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: Drop Down Menu


Message #1 by v_thomas@i... on Wed, 1 May 2002 15:46:19 +0530
Dear all,

Could anyone help me with a drop down menu in PHP and MySQL.

I got the following code but the database is Postgresql. If somebody
convert this to MySQL it will be great.
/////
$conn = pg_connect("host=localhost user=$user password=$pass dbname=$db");
if (!$conn) {
echo "Could not make a connection";
exit;
}
$sql = "select * from $table order by $orderBy limit $limit;";
$select_box = pg_Exec($conn, $sql);
$numrecords = pg_NumRows($select_box);
?>
<?
echo "<select name=select>";
//pre selected option
echo"<option value=none>select type</option>";
//loop through database to populate select box
for ($j=0; $j < $numrecords; $j++)  {
$value = pg_result($select_box, $j, "id"); //column name for the value of
the checkbox
$option = pg_result($select_box, $j, "category"); // select option column
name
echo"<option value=$value>$option</option>";
}
echo"</select>";
?>

Regards,

Thomas



IMPORTANT NOTICE:
This email is confidential, may be legally privileged, and is for the
intended recipient only.  Access, disclosure, copying, distribution, or
reliance on any of it by anyone else is prohibited and may be a criminal
offence.  Please delete if obtained in error and email confirmation to the
sender.


  Return to Index