Dracolas Posted November 3, 2009 Share Posted November 3, 2009 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 More sharing options...
mikesta707 Posted November 3, 2009 Share Posted November 3, 2009 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? Link to comment https://forums.phpfreaks.com/topic/180167-solved-displaying-rank-issues/#findComment-950443 Share on other sites More sharing options...
Dracolas Posted November 4, 2009 Author Share Posted November 4, 2009 thank you mikesta707. I tried that and it's working good. The ; is there because I keep in the habit of putting it there so if I put more code below it I don't have to add it later. Link to comment https://forums.phpfreaks.com/topic/180167-solved-displaying-rank-issues/#findComment-951080 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.