473,323 Members | 1,537 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,323 software developers and data experts.

Echoing out subcategories and all their items

1
sorted now thanks, please delete :)
Aug 9 '10 #1
1 1484
johny10151981
1,059 1GB
few observation about your mysql database.

in the table image some columns are unnecessary and problematic
Expand|Select|Wrap|Line Numbers
  1. image_id  name  parent    small_img    large_img    cat_id
name, parent these two columns are already exists in the first table. you do not need to repeat it here. Because you already have a unique id referenced from your first table name cat_id. using cat_id you easily can find out name and parent from table 1 if you need.

If you want to access row value using column name you need to use
mysql_fetch_assoc istead of mysql_fetch_row. follow the example below:
Expand|Select|Wrap|Line Numbers
  1. $row=mysql_fetch_row($result);
  2.  
  3. echo $row['category_id'];//catgory_id must have to pass as string not as constant.
  4. //this is wrong way
  5. echo $row[name];//it will make compilation error.
  6.  
Getting all the row:
Expand|Select|Wrap|Line Numbers
  1. #  $Row = mysql_fetch_array($result);            //get a row of the result, as an array
  2. #         while($Row) {                                //only while there is data in the row
  3. #             echo "          <li><a href='index.php?cat=$Row[category_id]'>$Row[name]</a></li>\n";
  4. #             $Row = mysql_fetch_array($result);        //get next row of results
  5. #         }
  6.  
your code can only access one line. but you need to access every row to process.
follow the link link. It will give you some good idea about how to get all the row. There is more. But I am little tired to finish all.
Aug 9 '10 #2

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

Similar topics

12
by: Donnal Walter | last post by:
The following method is defined in one of my classes: def setup(self, items={}): """perform setup based on a dictionary of items""" if 'something' in items: value = items # now do something...
4
by: Bill | last post by:
I've got a bookstore I'm developing, and I wanted to list all the categories on the home page of the site. However, there are so many, that they now extend way below the screen, making the page...
13
by: hornedw | last post by:
I have been working on a ecommerce website for myself. What I needed some assistance on was when i was trying to display the categories/subcategories for the different products. I decided to use...
3
by: vorange | last post by:
Hello, I have a problem I have been unable to solve for quite some time now. I'm using the Serialport class and opening the port and writing a byte to it. The byte is successfully received by...
1
by: vinayg | last post by:
how can i search subcategory wise for a particular category,i want to display items.suppose user selected a particular category.I want to display all items in that category + its subcategories. ...
1
by: jmDesktop | last post by:
I have read various things on subcategories. If there is only one subcategory for a main category it doesn't seem too bad, just another table, but I was wondering what some of you might recommend...
3
Staria
by: Staria | last post by:
Hi... I'm currently working on a project where I would like to have Categories and SubCategories. I've banged my head on this for several days, but can't seem to get this the way I want it to...
2
by: itpvision | last post by:
Hello, I have a link navigation of categories retrieved from the database, while I know how to display subcategories based on category link clicked with classical approach, I want to do this with...
1
by: myselfrandhawa | last post by:
Hi i have the following tables and i want to show categories and subcategories underneath them and count how many products exist in category and subcategory: i am allowing multiple categories for a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.