Jump to content

php LIMIT: +4 on next page and so on


y2yang

Recommended Posts

What I wanted to do is have php LIMIT to add 4 to [0, 4] on the next page id. What's going on is I am pulling data from MySQL and would like for page id 2 to add 4 to LIMIT so that it would start pulling data from row 5 and not row 1.

 

<?php
// database connection info


$query = "SELECT * FROM thumb LIMIT 0, 4";
$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 LIMIT 4, 4";
$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
}
?>

 

 

I am running 2 query on the same page, one with LIMIT 0, 4 and another one with LIMIT 4,4

 

Link to comment
https://forums.phpfreaks.com/topic/156631-php-limit-4-on-next-page-and-so-on/
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.