I have created a php site, and previously it was listing only products with defined values. I have now changed it to include an array of products for example all products WHERE id = "spotlights"

and this works great so it means I can add new products just to the database, but I still have to add the second page manually. e.g going from the product div on the main page, through to www.example.com/spotlight_1.php

Is there anyway in PHP to carry the data from my index.php e.g. the ID through to the next page? so that I can have a template product.php page, and I can use a database pull to echo the product information required.

So on index.php i click on the product with ID="1" and on the product.php page, it loads the relevant data for product 1.

I can write the php SQL/mySQL calls myself, its just the way to carry accross a value from the previous page which I dont understand

Regards

Henry

p.s.
all the IDs and things are stored in the database already as 1 to 3digit values e.g. 3 or or 93 or 254

Note: Be careful with the way you query your database, the previous code is only a demonstration of how to retrieve the info, but is not a secure solution. I recommend you to check PDO (http://php.net/manual/es/book.pdo.php).

is there anyway to run a $query variable from a GET like this? for example, I have the page index.php, and then it displays 3 types of products, index.php?type=1 , index.php?type=2 and index.php?type=3 then on the index.php page, id like to have $product_type = $_GET['type']; and then run the following query $query = "SELECT * FROM $usertable WHERE tabID LIKE '%$product_type%'"; is this possible?
–
Henry AspdenDec 5 '12 at 0:38

You can either keep passing the value forward in the request scope until you no longer need it (commonly passed in the url ?var=value), or you can also use sessions if this needs to live longer than the request scope.

There are a number of ways. You can put the data into session variables, you can POST the data to the 2nd page or pass the data via GET as URL parameters, or you can even save the data in a browser cookie.

Which approach you might use will likely depend on the security requirements for the data and whether you want to be able to access that data strictly via URL (in case of URL parameters).