0

I want to navigate through my website through page numbers assigned dynamically. e.g When I post a new topic it should be shown on the main page and the previous post should shift to "page no. 2" automatically. I want to do this without the use of a CMS.

amulous
  • 672
  • 2
  • 6
  • 15

1 Answers1

1

Use a foreach loop to loop through the posts, and for each post, create a link and display the link with the number you want like so:

(assuming the $posts is an array of url's)

<?
$page_number = 1;
foreach($posts as $key) { ?>
<a href="<?= $key; ?>">Page <?= $page_number; ?></a>
<? $page_number++ ?>

<?
} ?>
Jonah Katz
  • 5,082
  • 15
  • 65
  • 90