This drop down list works for the bu( business unit) but I wanted to put the description of the bu (name) into the drop down so I added the value in the sql (see asterisks)location_description.
and now the drop down doesn't work. The drop down is completely blank and doesn't pull down.
function get_bu($search_bu) {
echo "<option value=''>Select BU</option>\n";
$sql="SELECT DISTINCT bu AS bu, location_description ";
$sql.-"FROM `mydb`.mytable ";
$sql.= "ORDER BY bu ";
$link = mysql_connect('myIP','myuser','mylogin');
mysql_select_db("pharm_cart_order",$link);
$result = mysql_query($sql,$link) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
$bu=$row['bu'];
$location_description=$row['location_description'];
$sel_bu=$search_bu== $bu ? 'SELECTED' : '';
echo "<option value='$bu' $sel_bu>$bu $location_description</option>\n";
}
}//end get_bu
Here is the form:
echo "<tr>";
echo "<th align='right'>BU</th>\n";
echo "<td><select name='search_bu' id='search_bu' onChange='fillZoneNm();'>\n";
get_bu($search_bu);
echo "</select>\n";
echo "</td>\n";
echo "</tr>\n";
The fillzonenm() is a AJAX function that works. All I really did is add the location_description in the AS bu, location_description qualifier. The sql does work.
thanks,