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:
$mysqlquery="SELECT * FROM $gid";
Change your function to this:
function outputscores($mysqlquery,$reverse=false)
{
if ($reverse==true)
$mysqlquery.=" ORDER BY id DESC LIMIT 25";
else
$mysqlQuery.=" LIMIT 25";
$result=mysql_query($mysqlquery);
while($row = mysql_fetch_array($result))
{
//Do output here
}
}
Here, by adding the words ORDER BY id DESC you will make the records be ordered in descending order of the 'id' column in your table. By typing ASC instead of DESC you can have them ordered in ascending order. Also, you can replace 'id' with any other column from your table, for example timestamp, score, etc.
Edit: Alternatively, you could also make a different function for adding the LIMIT and ORDER BY clause to the query. Then you could do something like this:
$reverse=false;//or true
$mysqlquery=addOrderBy("SELECT * FROM $gid",$reverse);
outputScores($mysqlquery);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With