Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/174587-getting-data-from-database-problem/
Share on other sites

cheers all its fixed :D

 

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.

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

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.