darkfreaks Posted February 4, 2008 Share Posted February 4, 2008 ok instead of limiting 50 entries a thread and then have the first couple dissappear kind of blows is there a way i can loop the following code with a limit of 25 entries per page? $query2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC LIMIT 0,50"; Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/ Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 do you mean that entries 1-25 show on page 1, 26-50 on page two and so on? Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457335 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 correct Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457336 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 $query2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC LIMIT 0,50"; google pagination. multiple ways to think it out. you set a pagenumber, $page=$_GET['page'];, $upperlimit=$page*25;, $lowerlimit=$upperlimit-25; and then $query2 = "SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC LIMIT $lowerlimit,$upperlimit"; Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457337 Share on other sites More sharing options...
darkfreaks Posted February 4, 2008 Author Share Posted February 4, 2008 now i get mysql_num_rows not a valid resource here is the line: $num=mysql_num_rows($result2); Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457343 Share on other sites More sharing options...
mikefrederick Posted February 4, 2008 Share Posted February 4, 2008 need more code Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457344 Share on other sites More sharing options...
Northern Flame Posted February 4, 2008 Share Posted February 4, 2008 if all you're trying to do is pagination, i wrote a tutorial here: http://forums.tizag.com/showthread.php?t=5670 Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457348 Share on other sites More sharing options...
tibberous Posted February 4, 2008 Share Posted February 4, 2008 Yes! I'll tell you how. $page = 1; // Set to 2 for the second page $result = mysql_query("SELECT * FROM vc_covenmessages WHERE catid='$catid' ORDER BY `id` DESC LIMIT ".(($page-1)*25).",".(25).""); while($row = mysql_fetch_row($result)) echo print_r($row, true) . "<br>\n"; Written but not tested, because I don't know how to make a database. LOL. Link to comment https://forums.phpfreaks.com/topic/89313-loop-help/#findComment-457354 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.