Alanmoss Posted May 29, 2006 Share Posted May 29, 2006 I'am trying to populate a drop down list from my date baseThe drop down list shows the correct number of entrys from the tablebut they are blank on the drop down list.What have I done wrong . I think its a simple syntax error but I just can't see it.Help please.Here's the code:[code]echo '<div align="center"><form method="get" action="users_online.php"><select name="type"><option value="">Choose a Category:</option>';// Retrieve and display the available categories.$query = 'SELECT * FROM currency ORDER BY currency_id';$result = mysql_query ($query);while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {//this line is the problem echo '<option value="'.$row['exchange_rate'].'">'.$row['country_name'].'</option>';}// Complete the form.echo '</select><input type="submit" name="submit" value="Go!"></form></div>';if(isset($_POST['type'])) { $name = $_POST['type'];echo'<p>'.$name.'</p>';}[/code] Link to comment https://forums.phpfreaks.com/topic/10700-mysql-syntax/ Share on other sites More sharing options...
Randy Posted May 29, 2006 Share Posted May 29, 2006 try changing MYSQL_NUM to MYSQL_ASSOCMYSQL_NUM returns an array like: [0] -> Hello [1] -> Hiwhereas MYSQL_ASSOC returns an array like: [Money] -> 12 [Tax] -> 17.5you can refer to a MYSQL_ASSOC array with $array['tax'] which is what you seem to be using Link to comment https://forums.phpfreaks.com/topic/10700-mysql-syntax/#findComment-39936 Share on other sites More sharing options...
Alanmoss Posted May 29, 2006 Author Share Posted May 29, 2006 [!--quoteo(post=378067:date=May 29 2006, 02:12 PM:name=Randy)--][div class=\'quotetop\']QUOTE(Randy @ May 29 2006, 02:12 PM) [snapback]378067[/snapback][/div][div class=\'quotemain\'][!--quotec--]try changing MYSQL_NUM to MYSQL_ASSOCMYSQL_NUM returns an array like: [0] -> Hello [1] -> Hiwhereas MYSQL_ASSOC returns an array like: [Money] -> 12 [Tax] -> 17.5you can refer to a MYSQL_ASSOC array with $array['tax'] which is what you seem to be using[/quote]Thanks Very Much it works. Link to comment https://forums.phpfreaks.com/topic/10700-mysql-syntax/#findComment-39950 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.