Porkie Posted September 17, 2009 Share Posted September 17, 2009 i have a database called genres, with and id field and a genre field in. My problem is on a different page i want to to show the data ive added in my genres database. is this the right code iam using or not because currently nothing is loaded =( <?php $sql1 = mysql_query("SELECT * FROM genres") or die(mysql_error()); echo mysql_num_rows($sql1); while($sql2 = mysql_fetch_array($sql1)) { echo "<option value='{$sql2['ID']}'>{$sql2['genre']}</option>"; } ?> </select></td></tr> cheers Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/ Share on other sites More sharing options...
Zane Posted September 17, 2009 Share Posted September 17, 2009 nothing at all? not even a BLANK option box have you looked at the view source to confirm there IS nothing at all Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/#findComment-920088 Share on other sites More sharing options...
Bricktop Posted September 17, 2009 Share Posted September 17, 2009 Hi Porkie, Replace your second echo statement with the below: echo '<option value="'.$sql2['ID'].'">'.$sql2['genre'].'</option>'; Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/#findComment-920096 Share on other sites More sharing options...
Porkie Posted September 17, 2009 Author Share Posted September 17, 2009 cheers all its fixed now just a little bit more help please if i only want to show a page to users which had administrator status, where would i add the code? and what would it be? i would then need to echo the stuff for an admin and echo the error message if you dont have the admin status set. Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/#findComment-920104 Share on other sites More sharing options...
Bricktop Posted September 17, 2009 Share Posted September 17, 2009 Hi Porkie, I would recommend you start a new thread for this, making sure you post the relevant code. Glad this problem is sorted. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/#findComment-920107 Share on other sites More sharing options...
Zane Posted September 17, 2009 Share Posted September 17, 2009 The most effective and accurate way of doing something like that is to first check to see if they're an admin/moderator/super user/etc/etc/ and THEN ... use include or require to pull in the restricted page. Most people will first start off checking the status and then echoing it out if they are admin...echoing the error if they aren't, echoing a different page if they're someone else..etc..etc you get my drift you'll need to make a templating system if you want to do it the "correct" way. If you're just trying to throw a school project together then by all means...echo one thing after another. Either way, starting from scratch you're going to have a rough road ahead of you authenticating users and doing stuff about it...like everyone else. But that's a different story and a different thread...as you said this thread is solved...so click solved and read up on some php authentication tutorials. There are a few on the main phpfreaks site itself..written by the same people on the forums Quote Link to comment https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/#findComment-920111 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.