Create Page Links

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi there,

I have built guestbook using mySQL.
I am left with one task: creating the links
to other pages. (page 1, page 2, page 3, etc.)
I already have the amount of pages, links for
'next'and previous, and everything else.
All i need is to create the links, but i don't know
how to do it.

If anyone can help that would be great.
The best would be if the current page isn't a link,
but the rest is, and if there is a dividing character
between each link/number like '-'.

Thanks in advance and a wonderful christmas.

Greetings knoak

Re: Create Page Links

knoak wrote:
Quoted text here. Click to load it

Something like this?

$curr_page = 3;
$numpages = 7;

for ($i = 1; $i < $numpages; ++$i) {
  if ($i > 1) echo ' - ';                             ## separator
  if ($i != $curr_page) {
    echo '<a href="page.php?p=', $i, '">, $i, '</a>'; ## link
  } else {
    echo $i;                                          ## no link

Post *your* code (or, better, a stripped down version of it).
Mail to my "From:" address is readable by all at /
== ** ## !! ------------------------------------------------ !! ## ** ==
may bypass my spam filter. If it does, I may reply from another address!

Site Timeline