Jump to content

Archived

This topic is now archived and is closed to further replies.

corillo181

links

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.