y2yang Posted May 3, 2009 Share Posted May 3, 2009 I am running two query with LIMIT on the same page, which I pulled from my MySQL with field id. $query = "SELECT * FROM thumb LIMIT 0, 4"; and $query = "SELECT * FROM thumb LIMIT 4, 4"; Would it be possible to have this programmed to change automatically with page id. Example, on ?id=1, it would have the above query but on ?id=2, it would run a query like the one below. $query = "SELECT * FROM thumb LIMIT 8, 4"; and $query = "SELECT * FROM thumb LIMIT 12, 4"; To put it simple: First query on ?id=1 would start pulling data from row 1 to 4 and the second query on ?id=1 to start pulling data from row 5 to row 8. While query 1 on ?id=2 start pulling data from row 9 to row 12 and query 2 on ?id=2 from row 13 to row 16. Here is example of code: <?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 } ?> The main reason why I wanted to perform 2 LIMIT on one page is that I wanted 8 images to show on one page with a dotted line in between my two row of image. The code to go between the 2 row of images is: <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> Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/ Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 Wow, you just love to start a lot of topics don't you? What's wrong with the other topic you have opened for this problem? Also, instead of having one query to limit 0, 4 and then another to limit 4,4, wouldn't it be the same as having it run from 0,8 in one query? Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824768 Share on other sites More sharing options...
y2yang Posted May 3, 2009 Author Share Posted May 3, 2009 You are totally right, only thing is I'm going to html it into two row of images, with 4 images on each row and a single dotted line in between the two row of images, and that's where the problem come in. How to implement that dotted line in between the tow row of images? To get the two rows, I can just set it 0,8 and fetch it and my table would have arranged it nicely into 2 rows, but than I won't get that nice dotted line in between as well, so sad. Here is what i'm talking about: vickizhao.net/starhome/photo/list.php Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824773 Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 On that site, the dotted line is below the 8 pictures (or the first row), so it makes perfect sense to do 0,8. Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824785 Share on other sites More sharing options...
y2yang Posted May 3, 2009 Author Share Posted May 3, 2009 lol, I was messing with the code. Can you believe it, I test the site ONLINE, wow bad me. It was only supposed to show 4 on top and 4 on bottom. visit again plz. Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824789 Share on other sites More sharing options...
Ken2k7 Posted May 3, 2009 Share Posted May 3, 2009 $query = "SELECT * FROM thumb LIMIT 0,8"; $result = mysql_query($query); $count = 0; while ($row = mysql_fetch_assoc($result)) { if ($count == 4) echo '-----------------------'; } You can do something like that. That was an example. You can replace it with the HTML you have up there. I'm lazy and it's late here. Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824792 Share on other sites More sharing options...
y2yang Posted May 3, 2009 Author Share Posted May 3, 2009 Thanks, I'll give it a try. btw, it's 2:18 am here, I'm as crazy. Link to comment https://forums.phpfreaks.com/topic/156634-2-query-of-limit-int-int-on-one-page-with-1st-int-auto-change/#findComment-824796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.