Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
MySQL - postoji li entry u tablici?

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side
View previous topic :: View next topic  
Author Message
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 06.10.2005 20:29    Post subject: MySQL - postoji li entry u tablici? Add user to your forum ignore list Reply with quote

zelim napraviti previous/next navigaciju u galeriji, ali problem je sto mi ID-evi ne idu po redu (tj ima "rupa" jer sam neke radove brisala, i brisat cu ih i dalje) pa jednostavno rjesenje $id-1 i $id+1 ne dolaze u obzir.

postoji li neko rjesenje da ja odmah u jednom queryju saznam koji je najmanji ID veci od zadanog ID-a i koji je najveci ID manji od zadanog ID-a? pritom ne trebam vaditi nikakve podatke iz baze, samo me zanima postoje li, ako ne postoji $id-1 da nadje drugi, treci, petnaesti... koji prvi dodje po redu.
znam da bi se moglo s for petljom koja ide od $id prema najvecem/najmanjem entryju, ali to ne dolazi u obzir jer je najmanje elegantno rjesenje i u svakom loopu zvao bi bazu (e alo, ima entry sa ID-em tim i tim?) i to je puno komunikacije s bazom bezveze. ako postoji naredba u MySQL-u, to je ono sto meni treba.

tnx unaprijed.

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
che.UP
mi3.crew


Joined: 07 Sep 2003
Posts: 2320
Location: zagreb

PostPosted: 06.10.2005 22:05    Post subject: Add user to your forum ignore list Reply with quote

potrpas id-eve u array i onda se setas sa prev() i next()?
nejde mi bas pisanje sad al ak treba pojasnit probat cu se skoncentrirat:)

_________________
UP | TypeTester | Accommodations App
Meni u Firefox-u ne radi AJAX
Back to top
View user's profile Send private message Visit poster's website
gog



Joined: 18 Jun 2004
Posts: 679
Location: zagreb

PostPosted: 06.10.2005 22:43    Post subject: Re: MySQL - postoji li entry u tablici? Add user to your forum ignore list Reply with quote

nel`chee wrote:
postoji li neko rjesenje da ja odmah u jednom queryju saznam koji je najmanji ID veci od zadanog ID-a i koji je najveci ID manji od zadanog ID-a? pritom ne trebam vaditi


Ne znam baš s jednim, ali s 2 radi Smile
Code:
SELECT MAX(id) AS prethodni  FROM tablica WHERE id<$trenutni_id

Code:
SELECT MIN(id) AS slijedeci  FROM tablica WHERE id>$trenutni_id
Back to top
View user's profile Send private message Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 06.10.2005 22:47    Post subject: Add user to your forum ignore list Reply with quote

eh che hvala na ideji ali mislim da je ovo gogovo rjesenje upravo to sto trazim Very Happy
ma kad sam napisala jedan, mislila sam jedan za svaki ID, znaci dva kverija ukupno... e hvala ti puno Very Happy perfect.
morala bi ic malo citat onaj manual kad budem imala vremena Confused

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 06.10.2005 23:16    Post subject: Add user to your forum ignore list Reply with quote

radi ko po spagi Very Happy
tnx jos jednom

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Phiber



Joined: 18 Apr 2004
Posts: 319
Location: Čakovec, Kroejša

PostPosted: 06.10.2005 23:56    Post subject: Add user to your forum ignore list Reply with quote

array i levo desno,
no....

select id from nekaj where id<od_trenutnog_id_a limit 1
mi govori:
selektiraj BILO KOJI MANJI ID OD trenutnog id-a.

znaci ak imas
1 2 3 4 6 7 8 9 i trenutni id je 7 onda ti on moze dati: 1 ili 2 ili 3 ili 4 ili 6, ne? Smile

_________________
- Xatrix Security news portal -- redizajn napravljen, al radim css Smile
- - TIP / Rapid IT : web design & hosting -- za ovog ne, taj je u ladici Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nel`chee



Joined: 08 Jul 2004
Posts: 2087
Location: Rijeka

PostPosted: 07.10.2005 00:36    Post subject: Add user to your forum ignore list Reply with quote

nope, procitaj ponovo
Code:
SELECT MAX(id) AS prethodni  FROM tablica WHERE id<$trenutni_id

pronadji najveci u tablici koji je manji od trenutnog ID-a Smile

bez brige, vec sam uploadala i radi bez greske, primjer: http://inobscuro.com/gallery/work/47/
(prikazuje se samo next jer ovaj ima najveci ID u galeriji)

_________________
art & design portfoliofree Photoshop brushes stuffsketchblogfacebook
Back to top
View user's profile Send private message Visit poster's website Twitter profile
Phiber



Joined: 18 Apr 2004
Posts: 319
Location: Čakovec, Kroejša

PostPosted: 07.10.2005 00:53    Post subject: Add user to your forum ignore list Reply with quote

djizus, nisam vidio MAX. ljuzer.

_________________
- Xatrix Security news portal -- redizajn napravljen, al radim css Smile
- - TIP / Rapid IT : web design & hosting -- za ovog ne, taj je u ladici Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Server-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group