Drop Down Menu

This code creates one drop down menu for each item in the table. I’d like all the items in the table to be in one drop down menu. Seems like something simple in the html, but I can’t figure it out. Any help is appreciated. Thanks.

[php]<?php

$query = “SELECT typeid, foodtype from intlfoodtype”;
$result = mysql_query($query);

echo “<table class=“ex3” border=“0”>\n”;
while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$typeid = $row[‘typeid’];
$foodtype = $row[‘foodtype’];

  echo "<tr><td width=\"100\">\n";
  echo "</td><td>\n";

  echo "<select>";
  echo '<option value="'.$typeid.'">'.$foodtype.'</option>';


  echo "</td><td>\n";
  echo "</td></tr>\n";

}
echo “”;
echo “\n”;

?>[/php]

Give this a try…

[php]<?php

$query = “SELECT typeid, foodtype from intlfoodtype”;
$result = mysql_query($query);

echo “<table class=“ex3” border=“0”>\n”;
echo “

<td width=“100”>\n”;
echo “\n”;
echo “”;

while($row=mysql_fetch_array($result, MYSQL_ASSOC))
{
$typeid = $row[‘typeid’];
$foodtype = $row[‘foodtype’];

  echo '<option value="'.$typeid.'">'.$foodtype.'</option>';

}

echo "</select>";
echo "</td><td>\n";
echo "</td></tr>\n";
echo "</tr></table>\n";

?>[/php]

It worked! Thank you! I appreciate it.

You can’t have an anchor tag inside a dropdown. :’(

However you can add an onClick even like this…

[php]google[/php]

Which will accomplish the same thing

Thanks!

Unfortunately this didn’t work either. I’m trying to loop through the catid numbers and link each one to the buyproducts page when selected from the dropdown. Thanks.

This does not work: [php]echo “<option onClick=”‘index.php?content=buyproducts&cat=$catid’">’.$name.’’;[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service