6.2. Modify Your Functions to Accept Page Parameters

Now that your entries have a page associated with them, you can start using the page as a filter to retrieve only the data that matches your current page. This is really similar to the way you used the id column to filter your query to only return one entry. By using the page, you filter the query to only return entries for one page.

6.2.1. Accepting Page Information in the URL

First—and this is very important—you need to somehow pass a page variable to your script. You do this in the same way that you previously passed an entry ID to the script, using the URL and the $_GET superglobal.

For example, you navigate to the following address to look at the blog page:

http://localhost/simple_blog/?page=blog ...

Get PHP for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.