corillo181 Posted June 16, 2006 Share Posted June 16, 2006 is there any way i could work a pagination in to this query?[code] <?php$query2=mysql_query("SELECT path FROM tra_cotm_photo WHERE photo_id='".$_GET['p']."' ORDER BY photo_id DESC ")or die(mysql_error());while($result=mysql_fetch_array($query2)){echo "<img sr=$result[path]/>";}?> [/code]now the only problem is that i'm getting the ['p'] from the link.. wich comes from a thumnail version of the photo..wha ti want to know is onc ei display this photo how can i work a pagination so ppl can hit next or bac to see the picture that is before of after that one? i treid it, but it doesn't work since the wuery is been specific to one picture and now the whole table.. is there another way of doing this?this is the link that pictures come from[code]<a href="cfv.php?m=<?php echo $info['cotm_id'];?>&p=<?php echo $path['photo_id']; ?>">[/code] Link to comment https://forums.phpfreaks.com/topic/12208-links/ Share on other sites More sharing options...
Zaxnyd Posted June 16, 2006 Share Posted June 16, 2006 How about running a query to pull all the ID's, then adding them into an array, sorting the array, and using their index numbers? Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46519 Share on other sites More sharing options...
corillo181 Posted June 17, 2006 Author Share Posted June 17, 2006 i tried that, but sinc ei'm using thumnail on my othe rpage and the page is divided into 4 paganation page.. everything someone clicks on a thumbnail it send the person to the same picture in the first page.. Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46546 Share on other sites More sharing options...
poirot Posted June 17, 2006 Share Posted June 17, 2006 Basically can use two selects, like:[code]$prev = "SELECT photo_id FROM photos WHERE photo_id<$current LIMIT 1";[/code][code]$next = "SELECT photo_id FROM photos WHERE photo_id>$current LIMIT 1";[/code]I hope this can give you a picture of it. Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46548 Share on other sites More sharing options...
corillo181 Posted June 17, 2006 Author Share Posted June 17, 2006 that seen like a good idea, but i would have no idea how to work that in to a link.. Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46555 Share on other sites More sharing options...
corillo181 Posted June 17, 2006 Author Share Posted June 17, 2006 i guess i did have an idea i know more than i think i made it work with your help thanx man, here the way i made it work..[code]<?php$month=$_GET['m'];$curent_id=$_GET['p'];$n=mysql_query("SELECT photo_id FROM tra_cotm_photo WHERE photo_id > $curent_id AND cotm_id='$month' LIMIT 1")or die(mysql_error());$next=mysql_fetch_array($n);if($next){echo '<a href='.$_SERVER['PHP_SELF'].'?m='.$_GET['m'].'&p='.$next['photo_id'].'>next</a>';}else{echo "next";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46569 Share on other sites More sharing options...
corillo181 Posted June 17, 2006 Author Share Posted June 17, 2006 why those the back one send me to the first id in the row.. in other words to the first pictures instea dof the previous one?[code]<?php$month=$_GET['m'];$curent_id=$_GET['p'];$b=mysql_query("SELECT photo_id FROM tra_cotm_photo WHERE photo_id<$curent_id AND cotm_id='$month' LIMIT 1")or die(mysql_error());$back=mysql_fetch_array($b);echo '<a href='.$_SERVER['PHP_SELF'].'?m='.$_GET['m'].'&p='.$back['photo_id'].'>back</a>';?>[/code] Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46571 Share on other sites More sharing options...
corillo181 Posted June 17, 2006 Author Share Posted June 17, 2006 any guess any one? Link to comment https://forums.phpfreaks.com/topic/12208-links/#findComment-46585 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.