MySQL Forums
Forum List  »  PHP

next/previous on a date select query
Posted by: ade harris
Date: July 04, 2010 01:32PM

i have a simple query which returns the next 3 events from todays date

$result = mysql_query("SELECT ID,djs,photo,comments,UNIX_TIMESTAMP(date) AS unixdate FROM test WHERE DATE(date) >= DATE(NOW()) ORDER BY date ASC LIMIT 3", $connection) or die("error querying database");
$i = 0;
while($result_ar = mysql_fetch_assoc($result)){

<?php echo date("l jS F", $result_ar['unixdate']); ?> etc etc

<?php
$i+=1;
}
?>

ID is an auto-incremental field

what i'd obviously like to be able to do is have a previous/next link that shows the prev/next 3 dates from the ones that are currently shown

since the dates entered wont necessarily be in the same order as the ID i cant simply take the id field and add +3 (or whatever)

i cant seem to find anywhere where this has been combined but it must be able to be done ?

Options: ReplyQuote


Subject
Written By
Posted
next/previous on a date select query
July 04, 2010 01:32PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.