Jump to content

PHP-MySQL - image pagination.


y2yang

Recommended Posts

Hello,

I have a PHP-MySQL script that need help with.

 

I would like a images pagination.

2 rows, 4 column.

With a dotted line in between the row.

 

What I want is to have image with id 1-4 to show on bottom row and image id 5-8 to show on top row, there's more images but that's on other page id.

 

Here is my code:

 

<?php
// database connection info
$conn = mysql_connect('..','..','..') or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db('..',$conn) or trigger_error("SQL", E_USER_ERROR);

$query = "SELECT * FROM thumb";
$result =  mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
?>
<div style="width:132px;height:132px;margin:0 5px 0 5px;float:left;">
        <table width="132" style="background:url('http://image.vickizhao.net/starhome/photo/list/img_pic_bg.gif') no-repeat;">
        <tr style="height:132px;">
            <td><a href="http://<?php echo $_SERVER['SERVER_NAME']; ?>/starhome/photo/read/read.php?Pid=<?php print $row['id']; ?>"><img id="reSizeImg1" src="<?php print $row['imgpath']; ?>" style="border:solid 1px #ffffff;" alt=""  /></a></td>
        </tr>
        </table>
    </div>
<?php
}
?>
			<div style="clear:left;overflow:hidden;width:0;height:0;"></div>
		    <p style="margin:20px;"></p>
			<div class="dotHLine1"></div>
			<p style="margin:20px;"></p>

<?php
$query = "SELECT * FROM thumb";
$result =  mysql_query($query);
while ($row = mysql_fetch_assoc($result)) {
?>
<div style="width:132px;height:132px;margin:0 5px 0 5px;float:left;">
        <table width="132" style="background:url('http://image.vickizhao.net/starhome/photo/list/img_pic_bg.gif') no-repeat;">
        <tr style="height:132px;">
            <td><a href="http://<?php echo $_SERVER['SERVER_NAME']; ?>/starhome/photo/read/read.php?Pid=<?php print $row['id']; ?>"><img id="reSizeImg1" src="<?php print $row['imgpath']; ?>" style="border:solid 1px #ffffff;" alt=""  /></a></td>
        </tr>
        </table>
    </div>
<?php
}
?>

 

The dotted line in between the two rows of images is generated with this code:

 

<div style="clear:left;overflow:hidden;width:0;height:0;"></div>

    <p style="margin:20px;"></p>

<div class="dotHLine1"></div>

<p style="margin:20px;"></p>

 

I would like for images with id 1-4 to show on bottom row and images with id 5-8 to show on top row. And images with id 9-12 to show on bottom row of next page and images 13-16 to show on top row of that page.

 

To see how the list looks like, please visit: http://vickizhao.net/starhome/photo/list.php

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/156520-php-mysql-image-pagination/
Share on other sites

Archived

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

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