I'm very new to PHP and MySQL and am in the process of creating an online shop with shopping cat facility but I have come across a problem.
My shop has categories which are displayed in a left hand menu and when categories are clicked, I would like basic product details and a picture displayed. When the category is selected, only a written description of the product comes up, no fancy pictures, and how can I specify how many pics per row I would like? Preferable 3 to a row, 9 to a page.
My code is:
<?php
....(code)....
$display_block = '<h1>My Categories</h1><p>Select a category to see its items.</p>';
//show categories first
$get_cats = "select id, cat_desc from Category order by id";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());
if (mysql_num_rows($get_cats_res) < 1) {
$display_block = "<P><em>Sorry, no categories to browse.</em></p>";
} else {
while ($cats = mysql_fetch_array($get_cats_res)) {
$cat_id = $cats[id];
$cat_desc = stripslashes($cats[cat_desc]);
$menu_block .= "<p><strong><a class=\"link1\" href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_des</a></strong></p>";
if ($_GET[cat_id] == $cat_id) {
//get Product
$get_Product = "select id, item_slogan, item_price, item_image from Product where cat_id = $cat_id order by item_slogan";
$get_Product_res = mysql_query($get_Product) or die(mysql_error());
if (mysql_num_rows($get_Product_res) < 1) {
$display_block = "<P><em>Sorry, no items in this category.</em></p>";
} else {
$display_block .= '<ul class="showitem">';
while ($Product = mysql_fetch_array($get_Product_res)) {
$item_id = $Product[id];
$item_slogan = stripslashes($Product[item_slogan]);
$item_price = $Product[item_price];
$item_image = $Product[item_image];
$display_block .= "<li><a class=\"link1\" href=\"showitem.php?item_id=$item_id\">$item_slogan</a>(£$item_price)";
}
$display_block .= '</ul>'";
}
}
}
}
?>Can anyone help?
Thanks