Jump to content

links


corillo181

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.