Jump to content

[SOLVED] Make posts continue on another page?


Recommended Posts

Hey,

I'm was wondering how I could make it so that after the first 15 posts it continues on another page for 15 and then another and another?

 

Kind of like the system here. When a certain amount of posts are on a page it creates a page two to continue with the posts...I'm at a lost with trying to do this

 

Thanks!

Ok,

Basically I'm using this http://www.phpfreaks.com/quickcode/Easy-Pagination-Application/653.php

 

The problem is that on my show.php page I have a $_GET of the id which tells the query which comments to display based of the news article id...but this pagination script requires me to use $_GET['page'] so it's not showing correctly....is there a way to incorporate two $_get variables in a URL? like /show.php?id=x and then show.php?a


Use this.

<?
$sql = mysql_query("select * from `table`"); //change this.
$num = mysql_num_rows($sql);
$limit = 25; //change this.
if($num > 0){
  $current_page =(!$_GET

)? 1:$_GET

; // is page set, if false default is 1.
  $limit_b = (($current_page * $limit) - $limit); //where to start at?
  $sql2 = mysql_query("SELECT * FROM `table` limit $limit_v, $limit"); //sets the pages
  while($album = mysql_fetch_array($sql_photo_album))
  {
    # your displaying stuff here.
  }
  
  # next page?
  $next = ($current_page == 1)?
  'Next | ':
  '<a href="page.php?page='.($current_page + 1).'">Next</a> | ';

  # current pages.
  $numofpages = ceil($num_rows / $limit);
  for($i=1; $i<=$numofpages; $i++)
  {
    $page.= ($i == $page_number)? $i.' | ': '<a href="page.php?page='.$i.''">Next</a> | ';
  }

  # prev
  $prev = ($current_page >= $num)? 'Prev':  '<a href="page.php?page='.($current_page - 1).'">Prev</a>';

   if($num > $limit) print $next.$page.$prev;
}else{
  print "no items";
}
?>

xyn's method isn't working with the whole page links...and all the variables are messed up in the code so after fixing all of that it still didn't do the page number correctly...

 

also for the script I'm using it won't display a link for the last couple of comments for some reason...i have to manually type the page after to get them to show...does anyone have a solution?

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.