Jump to content

Recommended Posts

ok i am building a paginating page query 50 results perpage using loop I am lost any ideas

Will Thank in advance  ???

 

function build_comments_form($pub, $status='pending', $page='0') {

$perPage = 50;
$start = $perPage * $page;
$page=0;


if($status ==  'all')
	$comments = mysql_query("SELECT * FROM tblcommentsall WHERE PubID232 = '".PUB_ID232."' ORDER BY comment_id DESC LIMIT $start,$perPage");
else
	$comments = mysql_query("SELECT * FROM tblcommentsall WHERE $status = 1 AND PubID = '".PUB_ID."' ORDER BY comment_id DESC LIMIT $start,$perPage");



$totalPages = mysql_num_rows($comments) / $perPage;

# if there is a previous page -> echo previous link
# if there is a previous page -> echo previous link
if($page > 1){
   $prev = ($page - 1);
   echo "<a href=\"<a href=\"http://205.147.195.141/sitesadmin/comments_dev/pub_index.php?status=$status&page=$prev\"><<Previous</a>";
}

if($page > 1){
   $next = ($page + 1);
   echo "<a href=\"<a href=\"http://205.147.195.141/sitesadmin/comments_dev/pub_index.php?status=$status&page=$next\">Next>></a>";
}

echo "</right>"; 

# for total number of pages 


	# loop though totalPages -> each page -> echo page # link
$page=1;
do
  {
  $page++;
  echo "" . $perPage . "<br />";
  }
while ($page<2);

 

 

Link to comment
https://forums.phpfreaks.com/topic/81223-pagnating-50-comment-results-to-a-page/
Share on other sites

please make sure your next topic is posted in the correct section - this has nothing to do with OOP. Also, you might want to be a bit more clear about what problems you're getting with the code - errors, issues, unexpected behaviour, etc. we can't just guess :)

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.