Code2Design.com

User login

The Layout

Programming

Graphic Design

Resources

Navigation

C2D Projects

Unsystematic Affiliates

Adobe Tutorialz Spoono Capital Tutorials Tutorials Expert 

Change Language

Who's online

There are currently 0 users and 13 guests online.

PHP Shopping Cart Menu

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


Submitted by adaniels11 on April 9, 2007 - 3:46pm.
printer friendly version

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <br /> <h3>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use BBCode tags in the text, URLs will be automatically converted to links
More information about formatting options



Like what you see?

Why not add more? C2D is looking for other Christian Web Masters who would like to help write articles for this site. If you have expericance in FLASH, CSS/HTML, PHP/MySQL, PhotoShop/GIMP, Blender, Javascript, or just General Design - our users would love to hear what you have to say. Contact Us

delicious   digg   reddit   magnoliacom   newsvine   furl   google   yahoo   technorati