Pandora would like a page for each product choice which gives more detail, photos, nutritional information and so on:
- create a new page which will hold give links to the information, call it productinfo.php
- put a main heading Product Information
- inside the main PHP block under the heading create an if/else statement with condition !$_GET["product"] which will test to see if the user has clicked on a product for information
- in the if part show the links for them to pick a product (no PHP needed) just as you did in getsend.php:
- create an unordered list
- each list item will be one of the items in the form (cheese, chicken, ham, bacon, sandwich, roll, wrap, gluten free etc. until you have all 20)
- make each of those into a link with the same href (productinfo.php) for now
- test the page and you should see the links, click on one and the page should reload as there is no $_GET data yet
- add $_GET data to the link URLs in the form ?product=cheese (do not use spaces or capitals in the data e.g. Gluten free would become glutenfree
- test the page again and this time after you click on a link you should see nothing apart from the heading (because the else has been triggered)
- in the else part of the main if:
- use print_r (like in getget.php) to test that the product data is getting through then delete that line or comment it out
- put the value from $_GET into a variable called $product
- echo the product variable as a heading: <h1>$product</h1>
Once the page is properly working put a link to it on the products.php page.
For this practise you are done. On a real site you would now put up information about each item but the best way to do that is to use a database. All that matters now is that the PHP works so that if you click on a link it takes you to the same page but with different information each time. The database comes later.
The end of PHP?
If you struggled with any of this do it again. Think up pages and sites of your own. Don't move on until you can quickly look up and do all of the stuff here (no one expects you to remember it all). Programming is alien to most people so train your brain by lots of practise just like you would if you were going to speak a language, play a sport or do other challenging things in life. Once HTML, CSS and PHP are almost automatic you will be ready for SQL.