mybluehair Posted November 19, 2007 Share Posted November 19, 2007 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? Quote Link to comment Share on other sites More sharing options...
Wes1890 Posted November 19, 2007 Share Posted November 19, 2007 $sql = mysql_query("SELECT rank FROM users WHERE id='".$YOUR_LOGGED_ID."'); $row = mysql_fetch_array($sql); That selects the rank and puts it in an array, now check it with this: if ($row['rank'] == 2) { //we are admin } else { //we're not admin } Quote Link to comment Share on other sites More sharing options...
nuxy Posted November 19, 2007 Share Posted November 19, 2007 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. Quote Link to comment 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.