Jump to content

Recommended Posts

Ok I'm setting up my Memberslist page on my site and i'm using a rank system.

 

I've got the array working... I've got the query working...but when i do

 

$crank = $rank[$row['rank']];
$result = mysql_query("SELECT * FROM users");

while($row = mysql_fetch_assoc($result)){
   echo "<br>Name:".$row['username'];
   echo "<br>Rank: "; echo $crank;
} ;

it only displays the first rank in the database but when I do

while($row = mysql_fetch_assoc($result)){
   echo "<br>Name:".$row['username'];
   echo "<br>Rank: " .$row['rank'];
} ;

it displays each members rank as a number...how do I get it to display using the array with the when...

 

Thank you !

Link to comment
https://forums.phpfreaks.com/topic/180167-solved-displaying-rank-issues/
Share on other sites

in this example

$crank = $rank[$row['rank']];
$result = mysql_query("SELECT * FROM users");

while($row = mysql_fetch_assoc($result)){
   echo "<br>Name:".$row['username'];
   echo "<br>Rank: "; echo $crank;
} ;

 

the crank is only set once. Perhaps you meant to do


$result = mysql_query("SELECT * FROM users");

while($row = mysql_fetch_assoc($result)){
   $crank = $rank[$row['rank']];
   echo "<br>Name:".$row['username'];
   echo "<br>Rank: "; echo $crank;
}//why was there a semi colon here?

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.