L Posted November 24, 2007 Share Posted November 24, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/ Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 The concept is known as 'pagination': http://www.phpfreaks.com/quickcode_cats/33/Pagination.php Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398330 Share on other sites More sharing options...
L Posted November 24, 2007 Author Share Posted November 24, 2007 Shoot, I was hoping it'd be easier than that but o well. Thanks for the link...I'll post back if I have any questions Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398332 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 It is easy. The concept is to just get a selection of results. Which results is offset by a passed page variable that is multiplied by the quantity of results. Then you want to make a set of links... Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398335 Share on other sites More sharing options...
L Posted November 24, 2007 Author Share Posted November 24, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398361 Share on other sites More sharing options...
xyn Posted November 24, 2007 Share Posted November 24, 2007 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"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398364 Share on other sites More sharing options...
0x00 Posted November 24, 2007 Share Posted November 24, 2007 use as many $_GET and $_POST as you want... (e.g. can use 'get' in form, as in example): <form action="apage.phtml?id=0x00&page=thatone" method="post"> To re-iterate, to use multiple, just separate them with '&'... Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398373 Share on other sites More sharing options...
L Posted November 25, 2007 Author Share Posted November 25, 2007 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? Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398561 Share on other sites More sharing options...
L Posted November 25, 2007 Author Share Posted November 25, 2007 0x00 method seems to work now that I redid the original script...thanx for the help, it's working beautifully now Quote Link to comment https://forums.phpfreaks.com/topic/78712-solved-make-posts-continue-on-another-page/#findComment-398574 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.