I am new to PHP and need help with a website I'm creating. Using a MySQL database I have created a table storing all of my images, descriptions, links etc. I need the product images to display on the PHP page (which I've already figured out) and be links to their individual product pages (help!) which are also dynamic. How do I code that so when the product is selected a new PHP page loads with that specific product, description, etc?

9 Years
Discussion Span
Last Post by sDJh

0) Preperation:
Give all items a unique ID or name.
1) Index-Page
Ouput all items and link then to the product-page with their ID

echo "<a href=\"product.php?item=".$row["ID"]."\">".$row["Title"]."</a>";

2) Programme the product-page:
Output more detailed information about the seleted product

mysql_query("SELECT *  FROM `products` WHERE `ID`=".$item);

Have a look at other threats here to see how to check if the variable $item isn't corrupted.


thanks! i got the images to link correctly. now i'm working on the product page itself. how do i run the query to pull that products specific image, description + any thumbnails for that product automatically? again, thank you for any help.


exactly the way as i told you.

on the main page you link the images (headlines, etc) to the page product.php and add the ID of that product to it (eg "product.php?id=".$id).
The page product.php now selects all information about the specified product:

mysql_query("SELECT *  FROM `products` WHERE `ID`=".$id);

Thats all.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.