Hello everyone, i’ll make this brief, as I’m sure its very simple…
I am a designer first and foremost, so php/mySQL coding is relatively new to me, however, I am in the process of building an online store for a small business. I have used a table ‘products’ to hold all my products, with the following structure;
|id|product_name|price|category|description|product_image
I have been able to create a page which shows ALL the products, however, what I would like to do is have a list of categories down one side which, when clicked will go to a page showing all products with that category. My question, do I have to build a separate page for each category, or can I build one page, and carry through the category variable in the URL rather like the actual product view page I have… (i.e /product.php?id=2).
The code that outputs the products on the main store page is as follows;
[php]<?php
$dynamic_list = “”;
$sql = mysql_query(“SELECT * FROM products ORDER BY date_added DESC LIMIT 50”);
$productCount = mysql_num_rows($sql); // count the output amount
if ($productCount > 0) {
while($row = mysql_fetch_array($sql)){
$id = $row[“id”];
$product_name = $row[“product_name”];
$price = $row[“price”];
$date_added = strftime("%b %d, %Y", strtotime($row[“date_added”]));
$details = $row[“details”];
$dynamic_list .= ’
![]() |
'. $product_name .' £'. $price .' '. $details .' View Product |
?>[/php]
I apologise if i’m not using the correct terminology, as i said, i’m relatively new to php programming, and have been building this store and a gallery by using bits and bobs from various tutorials around the web and modifying the code to try and figure it all out, learn by doing and all that…
Many thanks in advance!
Joe