Page is a not externally linkable
- Code, Content, and Presentation
-- Databases
---- Query database for previous dated event


MikeElmore - 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?


Thread source:: http://www.webmasterworld.com/databases_sql_mysql/4336172.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com