View Single Post
Old 04-24-2004, 06:45 PM   #16 (permalink)
bdl
Senior Contributor
 
Join Date: May 2002
Location: vta.ca.usa
Posts: 555
bdl is on a distinguished road
Ah, ok I see now; you're trying to match only one record, and you know the following 7 records will NOT match the criteria. So the query I've given you should only grab one record, which it does. My bad.

Now the way I see it, we can still use the exact same method, and tweak the query slightly so it will grab the one that matches plus the next 7. Based on what I can understand (and I think I've got it now), the 'next 7' records you want to retrieve are solely those events that take place after the single event you need to match. So we can safely assume that any record that has a start_time greater than the time you've provided in the WHERE clause will be one you want, i.e. they will be events that take place immediately after that one. Correct?

With this in mind, change the query I've given you to this instead:
PHP Code:
$query = <<< END
  SELECT *
  FROM 
{$today}
  WHERE 
{$timestamp} BETWEEN start_time AND end_time
  OR 
{$timestamp} < start_time
  LIMIT 8
END; 
Now that should work.

Obviously change the '*' to the select only the fields you want; I've kept my example short and am selecting every column for the sake of brevity.
bdl is offline   Reply With Quote