I'm building an on line store, and would like to query specific (categories) from my DB to display. The home page will query and displays the last 10 products just fine, but what's the best practice for my categories? Here's what I have (using Dreamweaver).
Warning: More then a few thing may look strange, but I'm willing to gut those smaller problems out later. The most pressing at the moment is this.
this is my HOME PAGE.
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Run a select query to get my letest 6 items
// Connect to the MySQL database
include "storeadmin/connect_to_mysql.php";
$dynamicList = "";
$sql = mysql_query("SELECT * FROM products ORDER BY date_added DESC LIMIT 10");
//
//
$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"]));
$dynamicList .= '<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td width="17%" valign="top"><a href="product.php?id=' . $id . '"><img style="border:#FFF 1px solid;" src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="110" height="150" border="1" /></a></td>
<td width="83%" valign="top">' . $product_name . '<br
/>
$' . $price . '<br />
<a href="product.php?id=' . $id . '">View Product Details</a></td>
</tr>
<hr />
</table>';
}
} else {
$dynamicList = "We have no products listed in our store yet";
}
//
///
mysql_close();
?>
mysql_close();
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Home Page</title>
<link rel="stylesheet" href="style/style.css" type="text/css" media="screen" />
<script src="/SpryAssets/SpryMenuBar.js" type="text/javascript">
</script>
<script src="../js/jquery-1.4.2.js" type="text/javascript"></script>
<link href="/SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#username").blur(function() {
$("#nameresponse").removeClass().text('Checking Username...').fadeIn(1000);
$.post("scripts/check_signup_name.php",{ username:$(this).val() } ,function(data) {
$("#nameresponse").fadeTo(200,0.1,function() {
$(this).html(data).fadeTo(900,1);
});
});
});
});
function toggleSlideBox(x) {
if ($('#'+x).is(":hidden")) {
$('#'+x).slideDown(300);
} else {
$('#'+x).slideUp(300);
}
}
</script>
<style type="text/css">
<!--
.style26 {color: #FF0000}
.style28 {font-size: 14px}
.brightRed {
color: #F00;
}
.textSize_9px {
font-size: 9px;
}
-->
</style>
</head>
<body>
<div align="center" id="mainWrapper">
<?php include_once("template_header.php");?>
<div id="pageContent">
<table width="100%" border="0" cellspacing="0" cellpadding="10">
<tr>
<td width="32%" valign="top"><h3>Categories</h3>
<p><?php include_once("category.php");?>
</p>
<p></p></td>
<td width="35%" valign="top"><h3>Products</h3>
<p><?php echo $dynamicList; ?><br />
</p>
<p><br />
</p></td>
<td width="33%" valign="top"><h3>Handy Tips</h3>
<p> </p></td>
</tr>
</table>
</div>
<?php include_once("template_footer.php");?>
</div>
</body>
</html>
The CATEGORY.php
<script src="/SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="/SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css" />
<ul id="MenuBar1" class="MenuBarVertical">
<li><a class="MenuBarItemSubmenu" href="<a href="<?php if (isset($dynamicList['echo $dynamicList'])) { }
?> ">Acessories</a>
<ul>
<li><a href="/category.php? subcategory=blade_trays</a></li>
<li><a href="#">Carry Bags Racks</a></li>
<li><a href="#">Carry Bags Racks</a></li>
<li><a href="#">Neck Dusters</a></li>
</ul>
</li>
<li><a href="/category.php">Barber Jackets</a></li>
<li><a href="#" class="MenuBarItemSubmenu">Clipper Maintenance</a>
<ul>
<li><a href="#">Cleaning Brush Tools</a></li>
<li><a href="#">Oil & Grease</a></li>
<li><a href="#">Sprays & Liquids</a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Clipper Parts</a>
<ul>
<li><a href="#">Andis</a></li>
<li><a href="#">Oster</a></li>
<li><a href="#">Wahl</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Clipper Trimmer Blades</a>
<ul>
<li><a href="#">Andis Blades</a></li>
<li><a href="#">Oster Blades</a></li>
<li><a href="#">Pro-Mate Blades</a></li>
<li><a href="#">Wahl Blades</a></li>
</ul>
</li>
<li><a href="#" class="MenuBarItemSubmenu">Clippers Trimmers</a>
<ul>
<li><a href="#">Andis</a></li>
<li><a href="#">Oster</a></li>
<li><a href="#">Wahl</a></li>
</ul>
</li>
<li><a href="#">Combes Brushes</a></li>
<li><a href="#">Cutting Capes</a></li>
<li><a href="#">Hair Dryers</a></li>
<li><a href="#">Liquids Creams Talc</a></li>
<li><a href="#">Mirrors</a></li>
<li><a href="#">Sanitation</a></li>
<li><a href="#">Shaving Needs</a></li>
<li><a href="#">Shears Scissors</a></li>
</ul>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"/SpryAssets/SpryMenuBarRightHover.gif"});
</script>
I have tried
<?php
// Script Error Reporting
error_reporting(E_ALL);
ini_set('display_errors', '1');
?>
<?php
// Connect to the MySQL database
include "storeadmin/connect_to_mysql.php";
if(isset($_GET["category"])){
$category = $_GET["category"];
$subcategory = $_GET["subcategory"];
}
?>
changing the category and subcategory with no luck. is there a while loop I can run? I'm stuck
I've tried and changed so many things and have been in a state of ignorance for months.
Thank you in advance.........just for looking.