ok i am having an issue and cant figure it out. im retrieving my data and using a loop to output it but each time i do this the first result is not included!! why is the first result now showing up???? <?php $query="SELECT firstname, money FROM users ORDER BY money DESC"; $result=mysql_query($query); $firstname=mysql_result($result,0,"firstname"); //loop through each row outputting the data for ($x=1; $x<= 3; $x++) { $firstname=mysql_result($result,$x,"firstname"); $money=mysql_result($result,$x,"money"); echo "$x. $money -------- $firstname <br/>"; } ?> Code (markup):
The proper way: <?php $result = mysql_query('SELECT `firstname`,`money` FROM `users` ORDER BY `money` DESC') or die(mysql_error()); if (mysql_num_rows($result) == 0) { echo 'No results!'; } else { $x = 0; while ($items = mysql_fetch_array($results)) { $firstname = stripslashes($items['firstname']); $money = stripslashes($items['money']); $x++; echo $x.'. '.$money.' -------- '.$firstname.' <br/>'; } } ?> PHP: Also, get in the habit of using single slashes. Then, if you need to echo double quotes, you wont have to backslash the double quotes.