Forum Moderators: coopster
Whats the syntax for displaying page numbers? I don`t want anything fancy with "next" or "previous" links, just the page numbers. Each page number links to the relevant page except the current page, which is not displayed as a hyperlink.
Any help would be appreciated, thank you!
:)
for($i=1; $i<=$total_pages; $i++) {
if($i!=$current_page) {
echo "<a href='path_to_script/blah.php?page=$i'>$i</a> ";
}
else {
echo "$i ";
}
}
Then, of course, you need some kind of routine in your script that displays the correct "page", or interval of posts...
How to do that entirely depends on what the rest of your script looks like.
I`ve been playing around with this page number thing and just can`t get it working.
I`m using the following query to display the entries on the page:
$query = "SELECT * FROM weblog ORDER BY post_id DESC LIMIT $start, 5";
$result = mysql_query($query);
$rows = mysql_num_rows($result);
Now I`m assigning $start by doing:
$start = ($current_page - 1) * 5
Then doing:
for($i=1; $i<=$pagetotal; $i++) {
if($i!=$current_page) {
echo "<a href='index.php?page=$i'>$i</a> ";
}
else {
echo "$i ";
}
}
$pagetotal being set to "5" in a config file and is the amount of entries per page.
Well, I can get page numbers with the syntax index.php?page=1 etc, but they just refresh the same page.
As you can see I`m in a complete mess and have no idea what I`m doing.
I want to see 5 entries per page with relevant page links to the next page.
Am I a lost cause or what? :) I`m new to PHP so I`m not understanding this too well.
Can anyone help me out? Thanks!