View Full Version : Show if admin=1

12-05-2010, 09:01 PM
Hello. I'm coding a usersystem. And now I want a navigator witch only administators can see. If you are an administator admin=1 in PHPmyAdmin you will be able to see the links.

Any idea how I can do this?

12-05-2010, 10:22 PM
if ($admin==1){ echo "blablabla";}

12-06-2010, 03:08 PM
if ($admin==1){ echo "blablabla";}
Thanks. But I have a login system, and I'm having a box only admins should be able to see, so that's what I'm trying to do.

This is my code so far:

$admin = mysql_query("SELECT admin FROM post WHERE id='$logOptions_id' LIMIT 1");
if (isset($_SESSION['idx'])) {
if ($admin==1){ echo '<div id="title_orange">Staff tools</div>

12-06-2010, 03:14 PM
if ($admin==1) You need to fetch the value from the mysql result set using mysql_fetch_row() (http://php.net/mysql_fetch_row) or related.

12-06-2010, 09:57 PM
I've seen cookie systems in which the user has a user level.. Example 1 member 2 admin etc... So you could setup a database with Name, password, userlevel and have php grab the data using a cookie for the session.

Then, in the case you have that.. it would be like
if ($userlevel == "2"){?>blah Coding<?}?>

12-06-2010, 10:04 PM
As abduraooft mentioned, you need to fetch the result of the query:

if (mysql_result($admin, 0))