Skip to content Skip to sidebar Skip to footer

Creating A Product Page For Each Specific Item

I am working on my first website using Html, CSS, JS, PHP etc. I want to create a product page where the buyer would view the products. Then, by clicking on the product the buyer w

Solution 1:

No, you don't have to crate a new page for each product. You could and try to give every product in your overview a link like this:

<ahref="view_product.php?product=<?phpecho$product['id'] ?>">Link to product</a>

Then create one page. This page acts as a placeholder for all the products. We'll call this the product page. On the product page, you can get the data for this specific product like this:

$query = 'SELECT * FROM products WHERE id = "'.$_GET['product'].'"';

So now every product has its own page and the query stated above gets all the data on the current product.

Note

I'm not using prepared-statement here. This only a small demo on how to get the product. I would strongly advise you to use them! Otherwise, your website is exposed to an SQL-injection!

Post a Comment for "Creating A Product Page For Each Specific Item"