tdavid Posted August 14, 2013 Share Posted August 14, 2013 I would like to display all the food types in one drop down. This code displays each type in it's own drop down menu...any help is appreciated. I think it is a simple html or loop bracket issue. Thanks. <?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 "</select>"; echo "</tr></table>\n"; ?> Quote Link to comment Share on other sites More sharing options...
Yohanne Posted August 15, 2013 Share Posted August 15, 2013 http://www.w3schools.com/php/php_ajax_database.asp Quote Link to comment Share on other sites More sharing options...
Psycho Posted August 15, 2013 Share Posted August 15, 2013 <?php $query = "SELECT typeid, foodtype from intlfoodtype"; $result = mysql_query($query); $options = ''; while($row=mysql_fetch_array($result, MYSQL_ASSOC)) { $options .= "<option value=\"{$row['typeid']}\">{$row['foodtype']}</option>\n"; } echo "<table class=\"ex3\" border=\"0\">\n"; echo " <tr>\n"; echo " <td width=\"100\"></td>\n"; echo " <td>\n"; echo " <select>\n"; echo $options; echo " </select>\n"; echo " </td><td></td>\n"; echo " </tr>\n" echo "</table>\n"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.