PDA

View Full Version : PHP paging


tux
04-02-2008, 10:18 AM
Hi All,

I have populated a gallery with thumbnails, the set up is 3 thumbs to the left of the page with the main image to the right. You can see an example here (http://www.photographybydantucker.com/gallery2_backup.php).

All is fine but so far am calling all records and want to restrict it to the 3 thumbs per page.

Can anyone explain how to alter my code to acheive this.

Here is my PHP.....

<?php
require_once("Connections/PbyDTconnection.php"); // database connection
///////////////////////////////////////////

$ImgCatIDurl = $_GET['ImgCatIDurl'];
$ImageID = $_GET['ImageID'];
///////////////////////////////////////////
$query = sprintf("SELECT * FROM images where ImgCatID='$ImgCatIDurl'");
$result = @mysql_query($query);
$images = @mysql_fetch_array($result);
///////////////////////////////////////////
$query = sprintf("select * FROM images where ImageID='$ImageID'");
$result_main = @mysql_query($query);
$image_main = @mysql_fetch_array($result_main);
///////////////////////////////////////////
?>

and ....

<?php do { ?>
<div class="img_left2">
<div class="img1"><a href="gallery2.php?ImgCatIDurl=<?php echo $images['ImgCatID'] ?>&ImageID=<?php echo $images['ImageID'] ?>"><img src="Images/Gallery/Thumbs/<?php echo $images['ImgURLthumb'] ?>" alt="<?php echo $images['ImgTitle']?>" title="<?php echo $images['ImgTitle']?>" ></a></div>
</div>
<?php }while ($images = mysql_fetch_array($result)) ?>
</div>
<div class="img_right2"><p><span class="blue_bold">Description:</span> <?php echo $image_main['ImgTitle'] ?></p>
<div class="img2big"><a href="#"><img src="Images/Gallery/<?php echo $image_main['ImgURLmain'] ?>" alt="<?php echo $images['ImgTitle']?>" title="<?php echo $images['ImgTitle']?>" ></a></div>
</div>
</div>

Many thanks.

Regards, Paul

davidj
04-02-2008, 11:00 AM
this is a good tut

http://www.php-mysql-tutorial.com/php-mysql-paging.php

It is quicker for me to post this link because i dont have the time to write a tut at the moment

tux
04-02-2008, 11:48 AM
Thanks Dj,

Hope the new job is going okay. Miss your imput and jovial comments.

Hope you are back in full flow on the forum soon.

Regards, Paul