Dynamic Select Menus
I'm trying to populate some select menus with data out of a mySQL db...my problem is that nothing loads
here's my code...thank you in advance :)
//Function call
======
//Dynamic form selects
function cat_list($selected){
//Perform query
$sql = mysql_query("SELECT * FROM news_categories");
//Begin menu
echo "< select name=\"cat_id\">\n";
echo "< option value=\"NULL\">Please select</option>\n";
//Loop through cats
while ($row == mysql_fetch_array($sql)){
echo "< option value=\"" . stripslashes($row[cat_id]). "\"";
//if $selected = curr row, select item in menu
if ($selected == $row[cat_id]){
echo "selected";
}
echo ">" . stripslashes($row[cat_name]) . "</option>\n";
}
//Close select
echo "</select>\n";
}
here's my code...thank you in advance :)
//Function call
======
//Dynamic form selects
function cat_list($selected){
//Perform query
$sql = mysql_query("SELECT * FROM news_categories");
//Begin menu
echo "< select name=\"cat_id\">\n";
echo "< option value=\"NULL\">Please select</option>\n";
//Loop through cats
while ($row == mysql_fetch_array($sql)){
echo "< option value=\"" . stripslashes($row[cat_id]). "\"";
//if $selected = curr row, select item in menu
if ($selected == $row[cat_id]){
echo "selected";
}
echo ">" . stripslashes($row[cat_name]) . "</option>\n";
}
//Close select
echo "</select>\n";
}
