Expand|Select|Wrap|Line Numbers
- $catsql = "SELECT * FROM categories2;";
- $catres = mysql_query($catsql);
- echo " <br>";
- while($catrow = mysql_fetch_assoc($catres))
- {
- echo "<a class='" . products . "' href='" . $config_basedir
- . "/productchoices.php?id=" . $catrow['id'] . "'>"
- . $catrow['name'] . "</a><p class='" . products . "'>";
- }
- echo "<br> ";
In the database I have categories, categories2, categories3, and products. Categories are at the top, they are the main ones. A user clicks that and goes to a page with categories 2, which lists the main items specific to that category. Then they choose one and it goes to categories 3, which is a spread of different products for that category. Finally they click on one of the products they like and go to a details page which is the products. I want the categories 2 navigation to work on the categories 3 and products page, so users can easily go back to that section of clothing.
The database has this info stored for each category:
Expand|Select|Wrap|Line Numbers
- categories: id
- name
- categories2: id
- cat_id
- name
- categories3: id
- cat_id
- name
- products:id
- cat_id
- name
I have this code for the categories2 page (Theres a check in there to see if there are any products first, then it lists the main sections if there are):
Expand|Select|Wrap|Line Numbers
- <?
- $prodcatsql = "SELECT * FROM categories2 WHERE
- cat_id = " . $_GET['id'] . ";";
- $prodcatres = mysql_query($prodcatsql);
- $numrows = mysql_num_rows($prodcatres);
- if($numrows == 0)
- {
- echo "<p class='" . whiteheader . "'> <br>No Products<br> ";
- }
- else
- {
- $catsql = "SELECT * FROM categories2 WHERE
- cat_id = " . $_GET['id'] . ";";
- $catres = mysql_query($catsql);
- $camsql = "SELECT * FROM categories WHERE
- id = " . $_GET['id'] . ";";
- $camres = mysql_query($camsql);
- if($camrow = mysql_fetch_assoc($camres))
- {
- echo " <br>";
- while($catrow = mysql_fetch_assoc($catres))
- {
- echo "<a class='" . products . "' href='" . $config_basedir
- . "/productchoices.php?id=" . $catrow['id'] . "'>"
- . $catrow['name'] . "</a><p class='" . products . "'>";
- }
- }
- echo "<br> ";
- }
- ?>
Can anyone help me out? Thank you!!