473,396 Members | 2,036 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help me please!!

I'm trying to make an online store and have everything working so far. The only problem I am having is making a multi level navigation. When someone clicks "mens" section it brings up stuff like "tshirt", "hats", etc. That works fine, my problem is when they click on that I want the same sub navigation to be there so they can still look at "tshirt", "hats", etc without having to click "mens" again. I have this code already :

Expand|Select|Wrap|Line Numbers
  1.  $catsql = "SELECT * FROM categories2;";
  2.    $catres = mysql_query($catsql);
  3.  
  4. echo "&nbsp;<br>";
  5.  
  6.    while($catrow = mysql_fetch_assoc($catres))
  7.    {
  8.      echo "<a class='" . products . "' href='" . $config_basedir
  9. . "/productchoices.php?id=" . $catrow['id'] . "'>"
  10. . $catrow['name'] . "</a><p class='" . products . "'>";
  11.    }
  12.  
  13. echo "<br>&nbsp;";
The only problem with it, is it lists all the categories (Like girls tshirts, etc) as well. How do I limit it so its only for that specific section.

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
  1. categories: id
  2.                  name
  3. categories2: id
  4.                    cat_id
  5.                    name
  6. categories3: id
  7.                    cat_id
  8.                    name
  9. products:id
  10.              cat_id
  11.              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
  1. <?
  2.  
  3.    $prodcatsql = "SELECT * FROM categories2 WHERE
  4. cat_id = " . $_GET['id'] . ";";
  5.    $prodcatres = mysql_query($prodcatsql);
  6.    $numrows = mysql_num_rows($prodcatres);
  7.  
  8. if($numrows == 0)
  9. {
  10.    echo "<p class='" . whiteheader . "'>&nbsp;<br>No Products<br>&nbsp;";
  11.  
  12.  
  13. }
  14.  
  15. else
  16. {
  17.       $catsql = "SELECT * FROM categories2 WHERE
  18. cat_id = " . $_GET['id'] . ";";
  19.    $catres = mysql_query($catsql);
  20.  
  21.    $camsql = "SELECT * FROM categories WHERE
  22. id = " . $_GET['id'] . ";";
  23.    $camres = mysql_query($camsql);
  24.    if($camrow = mysql_fetch_assoc($camres))
  25. {
  26. echo "&nbsp;<br>";
  27.  
  28.    while($catrow = mysql_fetch_assoc($catres))
  29.    {
  30.      echo "<a class='" . products . "' href='" . $config_basedir
  31. . "/productchoices.php?id=" . $catrow['id'] . "'>"
  32. . $catrow['name'] . "</a><p class='" . products . "'>";
  33.    }
  34. }
  35. echo "<br>&nbsp;";
  36. }
  37. ?>
I've tried to take this code and use it for categories3, but it doesn't understand to get the id from categories. So it lists all of them instead of the ones specific to that id.

Can anyone help me out? Thank you!!
Dec 31 '08 #1
1 1204
Markus
6,050 Expert 4TB
jeremyjcochran,

When posting code in the forums, it is required that you wrap the code in [code] tags. You can do this by simply highlighting the code and then hitting the '#' button at the top of our editor (where you write your post). Doing this formats your code and, in return, helps our experts read it and give an answer.

If you have any doubts, you can have a look over our Posting Guidelines to get familiar with the rules.

Thanks,
Moderator.
Jan 1 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: LilleSkutt | last post by:
I am trying to create and instantiate a class into a created domain, so that I can unload the domain and replace the class (assembly .dll) while the main application is running, but I can't get it to...
14
by: TrvlOrm | last post by:
OK. After much playing around, I managed to get my frame page this far.. see code below. BUT...there are still errors with it, and what I would like to have happened is this: 1) On the Left...
3
by: radioman | last post by:
Hi all, I would appreciate some help please. I just need pointing in the right direction as I am at a loss. Basically I have a form (frmAddMaster) which displays two subforms "Master Stock...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
1
by: Chua Wen Ching | last post by:
Hi there, I have some problems when reading XML file. 1. First this, is what i did, cause i can't seem to read "sub elements or tags" values, so i place those values into attributes like this....
4
by: steroche | last post by:
I would REALLY appreciate help please please please! Im sure it is probably blindingly obvious to most of you but I am totally in the dark here!I am lost - i thought i had finally figured out this...
28
by: Tim_Mac | last post by:
hi, i'm new to .net 2.0, and am just starting to get to grips with the gridview. my page has autoEventWireUp set to true, which i gather is supposed to figure out which handlers to invoke when...
2
by: Richard | last post by:
Help please. I am trying to autofill a form text field from a select-box lookup. I have no problem doing this if the select-box is part of the form but because there are 5 possible select boxes...
0
by: uno7031 | last post by:
Help Please!!! Adding 5 Days to another Date in an access query Good Morning, Help please…. I am new to access and trying to write a query that will add 5 days between a RecDate and a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.