How To Get Links Every 10 Posts

Fait

Seasoned Veteran
Joined
Oct 15, 2010
Messages
4,407
Reaction score
561
FP$
2,054
Hey,

I think this is the correct place to post this, just a quick question

I am working on a PHP project locally that im hoping to launch soon development has been going well I have just one question, Says if there is 10 post on one page how to i get it to automatically create a link to another page full of 10 posts? after every 10 post on each page i want it todo this?

Thanks,

Spudster
 
I think you have to query sql, to limit 10 outputs....
Then to calculate the total number of pages, get the total entries and divide by 10
I have done this before. 🙂
 
Yep, Im half way there :cheer:

Code:
<?php
require "../database.php";

$per_page = 6;

$pages_query = mysql_query("SELECT COUNT(*) FROM pages_wall") or die ("Error");
$pages = ceil(mysql_result($pages_query, 0) / $per_page);

$page = (isset($_GET['page'])) ? (int) $_GET['page'] : 1;
$start = ($page - 1) * $per_page;

$query = mysql_query("SELECT status_by FROM pages_wall LIMIT $start, $per_page") or die ("Errors");

while ($query_row = mysql_fetch_assoc($query)) {

echo '<p>', $query_row['status_by'] ,'</p>';

}

if ($pages >= 1 && $page <=$pages) {
for ($x=1; $x<=$pages; $x++) {
echo '<a href="?page=' .$x. '">' .$x. '<a>';
}


}

?>

I made this earlier how do i get this to say 10 results on each page?
 
Actually I copied it from a tutorial
http://www.youtube.com/watch?v=wd4fE5fk-fk

Best way to learn still wrote it out from the video.


I Mark This As *Solved*


Thanks for the help

-- October 6th, 2012, 11:28 pm --

Ok, so i dont have to open a new thread i will specifi the issue here..

Anyway is it possible to get data from a sql data without refreshing the page?
ive heard of ajax and jquery but carnt find a exact tutorial that can help me learn as im mainly into php development at the moment..

Another thing im trying to learn is i want the pages to go from page.php?pid=1 to just site.com/page_name

How are these possible

Thanks for your support while i learn 😉
 
Back
Top Bottom