coolguyraj
03-12-2009, 09:20 AM
I have this function that generate dropdown from mysql.
I want to midify this for update form (Ie i want to display the selected item first and the other choices after that.)
How can i do this.
Thanks.
function dropdown()
{
// open connection
$con = mysql_connect('test', 'user', 'pass');
// select database
mysql_select_db("test", $con);
//this code is bringing in the values for the dropdown.
$query="select buildingId,Name from buildings order by Name";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
while($row=mysql_fetch_array($result)){//Array or records stored
echo "<option value=$row[buildingId]>$row[Name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
}
?>
I want to midify this for update form (Ie i want to display the selected item first and the other choices after that.)
How can i do this.
Thanks.
function dropdown()
{
// open connection
$con = mysql_connect('test', 'user', 'pass');
// select database
mysql_select_db("test", $con);
//this code is bringing in the values for the dropdown.
$query="select buildingId,Name from buildings order by Name";
/* You can add order by clause to the sql statement if the names are to be displayed in alphabetical order */
$result = mysql_query ($query);
while($row=mysql_fetch_array($result)){//Array or records stored
echo "<option value=$row[buildingId]>$row[Name]</option>";
/* Option values are added by looping through the array */
}
echo "</select>";// Closing of list box
}
?>