y2yang Posted May 3, 2009 Share Posted May 3, 2009 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 More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 $page_id = is_int($_GET['id'])? $_GET['id'] : 0; $query = 'SELECT * FROM `thumb` LIMIT ' . $page_id . ', ' . $page_id + 4; yes? Link to comment https://forums.phpfreaks.com/topic/156631-php-limit-4-on-next-page-and-so-on/#findComment-824741 Share on other sites More sharing options...
y2yang Posted May 3, 2009 Author Share Posted May 3, 2009 let me see... Link to comment https://forums.phpfreaks.com/topic/156631-php-limit-4-on-next-page-and-so-on/#findComment-824743 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.