| Query database for previous dated event Please help me find my way! |
MikeElmore

msg:4336174 | 4:46 am on Jul 7, 2011 (gmt 0) | Ok so here is the deal: I have a page that displays details for (event A). at the end of the details I want to check if there is an event occurring before event A's date. If there is I want to display a link to event B but I can't figure out how to do this. This is what I have:
$prev_search = "SELECT title FROM events WHERE date < " . strtotime($event_data['date']); $find_event = mysql_query($prev_search); if (mysql_num_rows($find_event) != 0) { $prev_event = mysql_fetch_array( $find_event ); echo "<a class=\"readmore\" href=\"" . $base_url . "events/" . str_replace(" ", "_", $prev_event['title']) . "\">« Previous Event</a>";
}else{} Which works in only displaying the "previous" button if there is an event before this one, but i want it to only display the previous date. you get what Im saying?
|
brotherhood of LAN

msg:4336310 | 12:00 pm on Jul 7, 2011 (gmt 0) | Mike, welcome to the forums Try: SELECT MAX(date),title Instead of: SELECT title This will invariably return one row with the 'largest' timestamp.
|
|
|