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

Recommended Answers

All 2 Replies

<?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();
}
?>

thanks a miljon!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.