We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,313 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Display position in mysql

I need a script that selects all from mysql, orders them DESC with highest money and prints out only where username=$_SESSION['username'],
so it will show
Your position is X/10

2
Contributors
2
Replies
8 Hours
Discussion Span
1 Year Ago
Last Updated
3
Views
sowh4t
Newbie Poster
10 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
<?php 
$Q = "SELECT * FROM `mysqltable` ORDER BY `money` DESC";
$R = mysql_query($Q);
$i = 1;
if($R !== false){
    while($row = mysql_fetch_assoc($R)){
        //echo "{$row['username']} is position number {$i}<br/>\r\n";
        if($row['username'] == $_SESSION['username']){
            echo "You are position number {$i}<br/>\r\n"; 
        }
        $i++;
    }
}else{
    echo "no results returned :".mysql_error();
}
?>
Biiim
Posting Pro
504 posts since Oct 2011
Reputation Points: 104
Solved Threads: 83
Skill Endorsements: 7

thanks a miljon!

sowh4t
Newbie Poster
10 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0601 seconds using 2.65MB