Hello, im working on an article system and looking to avoid running three queries. example, i have this query:
SELECT id,title FROM articles WHERE id=$_GET[id]
now say $_GET[id] = 5
I would like to get the previous id 4 and the next id 6 (if there is one) so i can do something like:
<< Previous Article [Title] Next Article [Ttitle] >>
i would assume this is impossible without running mulitple queries? just thought i'd ask in case i am wrong. i am using mysql 4x
thanks
Is it possible to make a function that would increase/decrease a "counter" which would contain the page number that they were on? I am not sure about doing all this, since I am a bit new, but I believe that's what I'd investigate.
$pagenumber = thepagenumberthatweareon
int getNextPage(int currentPage, int scale), where scale 'up' or 'down'
function getNextPage($currentPage, $scale) { global $pagenumber; if ($scale = 'up') { return "$currentpage" + "1"; } else { return "$currentpage" - "1"; } }
That could be a totally bogus function, but I thought it'd be fun to throw that out. It at least gives you something to go on, I guess.
As long as we're looking at this, anyone want to suggest to me if I had done anything wrong with that function, and how I can improve on it?
Thanks -dant
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php