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
Related Article: Display data from mysql database in popup window?
is a PHP discussion thread by aianne that has 1 reply, was last updated 10 months ago and has been tagged with the keywords: php, css, html, database, mysql, mouseover, popup, box.
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
sowh4t
Newbie Poster
10 posts since Apr 2012
Reputation Points: 0
Solved Threads: 0
Skill Endorsements: 0
© 2013 DaniWeb® LLC
Page rendered in 0.0601 seconds
using 2.65MB