Jump to content

Pagnating 50 comment results to a page


nero1009

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 :)

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.