Jump to content

[SOLVED] need some simple php/mysql help


mybluehair

Recommended Posts

ok, im creating a chatroom using only php and mysql. ive gotten pretty far, and now i am running into a problem. i have gotten to the point were there is a member system. they have to be loged in to chat. well when they register it creates a new mysql row in a table called users. the feilds in this table are (in order) :

id, Username, Password, Name, Email, Date, IP, Actkey, Activated, rank

 

as you see at the end "rank". there are only 2 different things that can be. 1 or 2. 1 means your just a regular member. 2 means your a admin. now my problem is i need a php code that will grab that info if your a 1 or a 2. and then i need to make a if statement like maybe:

if($rank == 2){

echo "<center><a href=\"ap.php\">Admin panel</a></center><br>";

} else {

    }

so i need a way to do this and i dont know how. can someone please help me?

Link to comment
Share on other sites

I don't quite understand your problem, but if I am correct..

<?php
$connect = mysql_connect([i]host[/i], [i]user[/i], [i]password[/i]);
mysql_select_db([i]database[/i], $connect);
$query = mysql_query("SELECT `rank` FROM `users` WHERE `id` = '" . $current_id . "'", $connect);
if (mysql_result($query, 0) == 2) 
   echo '<p align="center"><a href="admin.php">Administration</a></p>';
?>

 

Else, please explain a bit more in detail what you want to accomplish.

Link to comment
Share on other sites

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.