fife Posted July 11, 2012 Share Posted July 11, 2012 ok I have a function that querys a table for information then creates a loop for a dropdown list. I really would like it done the way it is at the minute however its not working. The dropdown is empty and it stops the rest of the form after the field from loading. Error reporting brings back no errors. Here is the code //in the header function createoptions($table , $id , $field) { $sql = "select * $table ORDER BY $field"; $res = mysql_query($sql) or die(mysql_error()); while ($a = mysql_fetch_assoc($res)) echo "<option value=\"{$a[$id]}\">$a[$field]</option>"; } //and the form field <label for="networks" ></label> <select name="networks" id="networks"> <?php createoptions("networks", "idnetworks", "netname"); ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/265512-simple-loop-issue/ Share on other sites More sharing options...
Pikachu2000 Posted July 11, 2012 Share Posted July 11, 2012 I'm surprised it isn't throwing an error with no 'FROM' in the query string. Not sure why you're using variable array index $id there; it doesn't look like that's what you need. Quote Link to comment https://forums.phpfreaks.com/topic/265512-simple-loop-issue/#findComment-1360737 Share on other sites More sharing options...
PFMaBiSmAd Posted July 11, 2012 Share Posted July 11, 2012 Because the php code is being executed inside of a html <select ></select> tag, any mysql_error output from the code will only be in the 'view source' in your browser. Quote Link to comment https://forums.phpfreaks.com/topic/265512-simple-loop-issue/#findComment-1360738 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.