Jump to content

loop help?


darkfreaks

Recommended Posts

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

$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

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

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.