I recently followed a tutorial on making php divide output into pages and display previous 1 2 3 4 next etc on the pages. However, my select function does not now sort on the date as I have requested. $max_results=8; //Work out the limit for the query based on //current page numer $from = (($page * $max_results) - $max_results); //Perform MySQL query on only the current page number's resluts // descending order of date, followed by limit of query $sql=mysql_query("SELECT DATE_FORMAT(gigs.date,'%W %e %M , %y ') as date, venue, town FROM gigs ORDER BY date desc LIMIT $from, $max_results"); while(@$row=mysql_fetch_array($sql)){ //Build formatted result here echo("<h4>"); echo $row['date'] ; echo ("<br>"); echo $row['venue']; echo (", "); echo $row['town']."<br/>"; echo ("<p>"); echo("</h4>"); } PHP: This is the output I get: As you can see, it isn't sorting. I can't seem to get this right. Any help would be appreciated. cheers Harlequeen
Replace the query by this # $sql=mysql_query("SELECT DATE_FORMAT(gigs.date,'%W %e %M , %y ') as date, venue, town FROM gigs ORDER BY gigs.date desc LIMIT $from, $max_results"); # PHP:
I would rename your "date" field to something else... you never want fields or variables with names that might conflict with functions.