Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.