Jump to content


Photo

links


  • Please log in to reply
7 replies to this topic

#1 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 16 June 2006 - 11:28 PM

is there any way i could work a pagination in to this query?

<?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]/>";}?>



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

<a href="cfv.php?m=<?php echo $info['cotm_id'];?>&p=<?php echo $path['photo_id']; ?>">


#2 Zaxnyd

Zaxnyd
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 16 June 2006 - 11:35 PM

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?

#3 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 17 June 2006 - 12:19 AM

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..

#4 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 17 June 2006 - 12:20 AM

Basically can use two selects, like:

$prev = "SELECT photo_id FROM photos WHERE photo_id<$current LIMIT 1";

$next = "SELECT photo_id FROM photos WHERE photo_id>$current LIMIT 1";

I hope this can give you a picture of it.
~ D Kuang

#5 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 17 June 2006 - 01:05 AM

that seen like a good idea, but i would have no idea how to work that in to a link..

#6 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 17 June 2006 - 02:46 AM

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..


<?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";
}
?>




#7 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 17 June 2006 - 02:59 AM

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?

<?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>';
?>




#8 corillo181

corillo181
  • Members
  • PipPipPip
  • Advanced Member
  • 896 posts

Posted 17 June 2006 - 04:48 AM

any guess any one?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users