Re: previous, current and next while looping

From: Date: Wed, 19 Jun 2002 20:07:32 +0000
Subject: Re: previous, current and next while looping
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-103007@lists.php.net to get a copy of this message
Wilbert. Not sure exactly what you are trying to do. I assumed you wanted the previous galleryID and next galleryID. If so -- try this. If not let me know, and I'll try and change the query. HTH. Good luck Dan. --------------------------------------- $sql = " SELECT gl.gallerID as galleryID, pgl.galleryID as pre_galleryID, ngl.galleryID as nxt_galleryID FROM gallery_list as gl LEFT JOIN gallery_list as pgl ON pgl.galleryID = (SELECT max(galleryID) FROM gallery_list as pg WHERE pg.galleryID < gl.gallery_id) LEFT JOIN gallery_list as ngl ON ngl.galleryID = (SELECT min(galleryID) FROM gallery_list as ng WHERE ng.galleryID > gl.gallery_id) WHERE gl.galleryID = '$galleryID' LIMIT 1"; ------------------------------------------------------------ Wilbert Enserink wrote:
Hi all, I'm doing this query and looping through the results: $result_ID_ID=mysql_query($gallery_list_query) OR die(mysql_error()); $counter=0; while ($queryresult_IDresult=mysql_fetch_array($result_ID_ID)) { $result_array['$counter']=$queryresult_IDresult; if ($result_array['$counter']['galleryID']==$galleryID) { $current_number=$counter+1; $current_item=current(($result_array)); $next_item=next($result_array);///////this doesn't seem te work. } $counter=$counter+1; } When it has found the right record with ID number $galleryID I also need the previous record and the next record. Anybody has any clue how to do this? thx Wilbert ------------------------- Pas de Deux Van Mierisstraat 25 2526 NM Den Haag tel 070 4450855 fax 070 4450852 http://www.pdd.nl info@pdd.nl -------------------------


« previous php.general (#103007) next »