Listing Tours
Explore how to create a PHP script for listing tours stored in JSON, implement navigation between listing and creation pages, and manage empty data scenarios to improve user experience.
Creating a new script to list tours
We start by creating another page script: pages/list-tours.php.
To make it accessible for users, we have to define a route for it in index.php:
In list-tours.php, we put the usual stuff:
Loading the tour data
Between the bootstrap phase and showing the header of the page, we should do some work. Load all the tour data from the tours.json file.
For starters, let’s just copy the code that does this from create-tour.php and paste it in list-tours.php: