You are here: Re: [PHP] mysql query « PHP « IT news, forums, messages
Re: [PHP] mysql query

Posted by Dan on 02/18/05 02:41

Sebastian wrote:
> 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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация