Jump to content

Recommended Posts

can sumone help me please I am trying to pull up a basic account level status using array to hold the rank of the user

 

the way it works is when user joins the site he is issused his basic newbe membership rank 0 I would like a way of checking the database to see if that user has been updated to rank 1/2 so on and if so for the script to select the right array for that persons level am not good at the coding game so alot of help will be needed thanks alot peeps

 

here the code

 

$ranks = array(
        0=>"Newbe",
        1=>"Basic",
        2=>"Super",
        3=>"Admin");

// User Account Level Check
$user_current_level = $row["userlevel"];  // database table name is [  userlevel  ]

$query = mysql_query("SELECT username FROM accounts WHERE userlevel = '$user_current_level'") // want it to check the database for the current userlevel and then show it in text from the array what level that person is..
or die(mysql_error());
$row = mysql_num_rows($query);

if ($user_current_level < 3){
$user_current_Rank = "ADMIN";}
else{
$user_current_Rank = @$ranks[$user_current_level]; // get other level
}

 

hope sumone can help me cheers

Link to comment
https://forums.phpfreaks.com/topic/68873-account-level-array-problems-help-needed/
Share on other sites

start with a select query to determine the rank:

 

$q="SELECT * FROM member WHERE id='whatever' ;";
$sql=mysql_query($q);
$r=mysql_fetch_array($sql);

$rank=$r['rank'];

 

Then do a switch statement on the rank:

 

switch($rank){
case '0':
// mysql code to update the rank goes here(?)
break;

case '1':
echo 'User rank 1... do whatever you should for user rank 1';
break;

case '2':
echo 'User rank 2...';
}

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.