Reply to Re: Previous and Next ID ?

Your name:

Reply:


Posted by Stefan Rybacki on 07/23/05 14:35

Otto wrote:
> Hello
>
> Could somebody help me to resolve this problem?
>
> I have a fist php script where I make a query on table.
> In this script I display the selected query (table) by
> name.
> When I click on a record I call a second php script where I
> display this record in details.
>
> // Query from the second PHP script:
> $query = "SELECT DATE_ENR, NO_ADR, FAMILLE, POLITESSE, NOM,
> ADR1, ADR2,RUE,CD_PAYS, PAYS, NP, CANTON, LIEU, TEL, FAX,
> TEL_OPT, TEL_OPT_NO,INFO1, INFO2, INFO3, GROUPE1, GROUPE2,
> GROUPE3, GROUPE4,GROUPE5, GROUPE6, GROUPE7, GROUPE8,EMAIL,
> WEB FROM adresse WHERE ID=$id order by nom";
>
> I like also to know the next and previous ID from the
> selected table (ID). But alphabetically
>
> Sample:
> ID NOM
> 145 Armand <-- previous
> 123 Dupont <-- selected ID
> 111 Martin <-- next
>
> How can I do that ?
>

Maybe this way:

previous:
SELECT * FROM adresse WHERE nom<='Dupont' AND id<>123 ORDER BY nom DESC LIMIT 1

next:
SELECT * FROM adresse WHERE nom>='Dupont' AND id<>123 ORDER BY nom ASC LIMIT 1

Regards
Stefan


> Many thanks in advance for your help.
>
> Regards
>
> Otto
>
>
>

[Back to original 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

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