I'm so excited!! 😃
I've posted this on two other boards, and no one has been able to help. I have another issue I can't figure out, that the other two boards couldn't help with, I'll ask about it after I get this one resolved. I so happy!
My data is stored in MySQL. I need just a tad more help with the script, if you don't mind. I am so new, but I've managed to create everything else.
Here's my categories table:
CREATE TABLE store_categories (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat_title VARCHAR(50) UNIQUE,
cat_desc TEXT
);
When the items under the categories are clicked, it uses this
table:
CREATE TABLE store_items (
id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
cat_id INT NOT NULL,
item_title VARCHAR(75),
item_price FLOAT(8,2),
item_desc TEXT,
item_image VARCHAR(50)
);
Lastly, here's the script for my seestore.php, which lists the categories, then products below the category when the category is clicked:
<?php
//connect to database
$conn = mysql_connect("localhost", "xxxxxx", "xxxxxx")
or die (mysql_error());
mysql_select_db("xxxxxx",$conn) or die (mysql_error());
$display_block = "<h1><font color=#808080 face=Arial, Helvetica, sans-serif>PPS Healthcare-Product Categories</h1>
<P>Select a category to see items available in that category.</p>";
//show categories first
$get_cats = "select id, cat_title, cat_desc from
store_categories order by cat_title";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());
if (mysql_num_rows($get_cats_res) < 1) {
$display_block = "<P><em><font color=#808080 face=Arial,
Helvetica, sans-serif>Sorry, no categories to browse.</em></p>";
} else {
while ($cats = mysql_fetch_array($get_cats_res)) {
$cat_id = $cats[id];
$cat_title = strtoupper(stripslashes($cats[cat_title]));
$cat_desc = stripslashes($cats[cat_desc]);
$display_block .= "<p><strong><a
href=\"$_SERVER[PHP_SELF]?cat_id=$cat_id\">$cat_title</a></strong>
<br>$cat_desc</p>";
if ($_GET[cat_id] == $cat_id) {
//get items
$get_items = "select id, item_title, item_price
from store_items where cat_id = $cat_id
order by item_title";
$get_items_res = mysql_query($get_items) or die(mysql_error());
if (mysql_num_rows($get_items_res) < 1) {
$display_block = "<P><em><strong>Sorry, no items in
this category.</strong></em></p>";
} else {
$display_block .= "<ul>";
while ($items = mysql_fetch_array($get_items_res)) {
$item_id = $items[id];
$item_title = stripslashes($items[item_title]);
$item_price = $items[item_price];
$display_block .= "<li><a
href=\"showitem.php?item_id=$item_id\">$item_title</a>
</strong> (\$$item_price)";
}
$display_block .= "</ul>";
}
}
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>P.P.S. Healthcare.com</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p align="center"><font color="#FFFFFF"> </font></p>
<p align="left"><font color="#FFFFFF"><img src="http://www.ppshealthcare.com/webgraphics/logo.gif" width="250" height="110" /> <img src="http://www.ppshealthcare.com/webgraphics/ppscredit.gif" width="100" height="14"> <font color="#000000" size="1" face="Arial, Helvetica, sans-serif">PPS
Healthcare Gladly Accepts Most Major Credit Cards Online</font></font></p>
<p align="left"><font color="#FFFFFF"><img src="http://www.ppshealthcare.com/webgraphics/greybar.gif" width="500" height="5"></font></p>
<p align="center"><font size="1" face="Arial, Helvetica, sans-serif"><a href="http://www.ppshealthcare.com/about.html"> About
PPS</a> | <a href="http://www.ppshealthcare.com/contact.html">Contact PPS</a> | <a href="http://www.ppshealthcare.com/productline.html">Product
Line</a> | <a href="http://www.ppshealthcare.com/showproducts.php">Order
Online</a> |<a href="http://www.ppshealthcare.com/faq.html"> F.A.Q.</a> |<a href="http://www.ppshealthcare.com"> Home</a></font></p>
<p align="center"><font color="#FFFFFF"><img src="http://www.ppshealthcare.com/webgraphics/order.gif" width="140" height="35" /></font></p>
<?php print $display_block; ?>
Would I perform the index page in this manner, using <?php print $display_form; ?> ?? :p It's probably not that simple, eh?
Anyways, thanks so much for the help!!
Allie