function outputscores($mysqlquery,$reverse=false) { while($row = mysql_fetch_array($mysqlquery)) { echo '<img src='img/date.png' /> ' . date('j M Y',strtotime($row['timestamp'])) . ' <img src='img/time.png' /> ' . date('H:i:s',strtotime($row['timestamp'])) . ' <img src='img/star.png' /> '.$row['score'].$_GET['scoretype'].'<br />'; } }
I need to reverse the array if $reverse is set to true, but PHP says that the mysql_fetch_array‘s output is not a valid array. Neither is $mysqlquery itself.
Is there any help?
Wow I’ve asked so many questions today ._.
EDIT
$result = mysql_query('SELECT * FROM $gid LIMIT 25') or throwerror(mysql_error()); outputscores($result);
EDIT2 Another possible call:
$result = mysql_query('SELECT * FROM '.$gid.',users WHERE users.lastcheck < '.$gid.'.timestamp') or throwerror(mysql_error()); outputscores($result);
Edit: Change your sql query to this:
Change your function to this:
Here, by adding the words
ORDER BY id DESCyou will make the records be ordered in descending order of the ‘id’ column in your table. By typingASCinstead ofDESCyou can have them ordered in ascending order. Also, you can replace ‘id’ with any other column from your table, for exampletimestamp,score, etc.Edit: Alternatively, you could also make a different function for adding the
LIMITandORDER BYclause to the query. Then you could do something like this: