Jump to content

[SOLVED] Individual Rank of each user


affc

Recommended Posts

Hello,

 

Just trying to display the number of each person individually from a table so that I can single out the individual rank for each person:

 

I get this error: Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' at ((( $individualrank[]=$rank; )))

 

For some reason it wont let me get the rank of ++$rank so I can view each persons rank individually when I post a search result for that person.

 

Thanx in advance if anyone can help me here :)

 

<?php
$sql="SELECT * FROM $tbl_name ORDER BY TOTAL DESC, UserName ASC";
$result=mysql_query($sql);
$counter=mysql_num_rows($result);
$rank=0;
while($rows=mysql_fetch_array($result)){
++$rank;
$individualrank[]=$rank;
$Checkusername[]=$rows['UserName'];
}
for($i=0;$i<$counter;$i++){
if($Checkusername[$i]==$_POST['username']){
echo $$individualrank[$i];
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/157041-solved-individual-rank-of-each-user/
Share on other sites

Sorry that was actually just a personal error I have changed now but still no good, the error is coming from trying to get the number of each row using the ++

<?php
$sql="SELECT * FROM $tbl_name ORDER BY TOTAL DESC, UserName ASC";
$result=mysql_query($sql);
$counter=mysql_num_rows($result);
$rank=0;
while($rows=mysql_fetch_array($result)){
$individualrank[]=++$rank;
$Checkusername[]=$rows['UserName'];
}
for($i=0;$i<$counter;$i++){
if($Checkusername[$i]==$_POST['username']){
echo $individualrank[$i];
}
}
?>

Yeah, if I do the following I get this result:

 

<?php
while($rows=mysql_fetch_array($result)){
echo ++$rank;
echo $rows['UserName'];

?>
}

 

Result =

1 Peter

2 Tom

3 Garry

4 Sally

5 Gill

etc etc etc

 

but i dont want to echo all of them, only want to display 1 person I have searched for with the POST function but still show their rank etc.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.