urtlking2jo Posted November 29, 2006 Share Posted November 29, 2006 I've stored the options I would like to use in a drop down box on multiple pages in a mysql db table. I am trying to run a query to retrieve those options (years in this case: 1990, 1991, 1992, etc.) and then store those options in an array so that I can output those options easily multiple times while only running the query once. I'm not overly familiar with arrays however, and am running into difficulty.My query is as follows, but I don't know where to go after that. Any help would be appreciated!$qry = "SELECT years FROM tbl_property WHERE login_name = '$fusername' AND room = '$room'";$result = mysql_query($qry); Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 29, 2006 Share Posted November 29, 2006 [code]<?php$qry = "SELECT years FROM tbl_property WHERE login_name = '$fusername' AND room = '$room'";$result = mysql_query($qry);$years = array();while ($row = mysql_fetch_array($result)) { $years[] = $row['years'];}//Then to create a select field (you could make this a function)echo "<select name=\"selectName\">";foreach ($years as $year) { echo "<option value=\"".$year."\">".$year."</option>";echo "<\select>";?>[/code] 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.