Welcome Guest, Not a member yet? Register   Sign In
Need help with writing a query!!!
#1

[eluser]heylarson[/eluser]
Suppose I have a mysql table called 'events' that looks as such.

Code:
id  start_date  title
--  ----------  -----
1   08-01-2010  foo
2   07-13-2010  bar
3   08-10-2010  foobar
4   07-21-2010  blah
5   08-16-2010  blah blah

The URL references the events by their event id as such, http://foo.com/event/2.

I would like to put a prev and next event links, on the current event the user is looking at. Obviously, the prev/next event links would point to the nearest events based off their 'start_date' and referenced by their 'id'.

For example, if you're looking at, http://foo.com/event/1, the prev link would be, http://foo.com/event/4, and the next link would be, http://foo.com/event/3.

I have tried sorting the events by 'start_date' and return the results as an array, but I can't seem to get the surrounding event id's for the currently viewed event.

Any help would be REALLY appreciated!!


Messages In This Thread
Need help with writing a query!!! - by El Forum - 08-24-2010, 01:02 PM
Need help with writing a query!!! - by El Forum - 08-24-2010, 01:42 PM
Need help with writing a query!!! - by El Forum - 08-24-2010, 02:09 PM
Need help with writing a query!!! - by El Forum - 08-24-2010, 02:40 PM
Need help with writing a query!!! - by El Forum - 08-24-2010, 03:40 PM
Need help with writing a query!!! - by El Forum - 08-24-2010, 06:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB