Kal
06-16-2006, 01:42 PM
The following code i have written works fine, it simply creates a drop down list which is populated from a mysql query, it display's a list of areas, and each area has a stock location and email address, all these attributes are put into an array.
what i want to do is modify it so that the drop down displays a default option "Please Select A Branch", i am having trouble trying to get this to work.
Any help is much appreciated. Thank You.
$query = "select brn_name,stk_loc,contact_emails from mc_mc.mc_brn_locations";
$result = mysql_query ($query) or die (mysql_error());
echo "<td><SELECT name=\"branch\">";
$loc=array();
if (mysql_num_rows($result)>0)
{
while($row=mysql_fetch_array($result))
{
#The following line, puts the rsults from the query into an array called $loc.
$loc[$row[brn_name]]=array($row[stk_loc],$row[contact_emails]);
echo "<option value=\"$row[brn_name]\">$row[brn_name]</option>";
}
}
echo "</SELECT></td>";
what i want to do is modify it so that the drop down displays a default option "Please Select A Branch", i am having trouble trying to get this to work.
Any help is much appreciated. Thank You.
$query = "select brn_name,stk_loc,contact_emails from mc_mc.mc_brn_locations";
$result = mysql_query ($query) or die (mysql_error());
echo "<td><SELECT name=\"branch\">";
$loc=array();
if (mysql_num_rows($result)>0)
{
while($row=mysql_fetch_array($result))
{
#The following line, puts the rsults from the query into an array called $loc.
$loc[$row[brn_name]]=array($row[stk_loc],$row[contact_emails]);
echo "<option value=\"$row[brn_name]\">$row[brn_name]</option>";
}
}
echo "</SELECT></td>";