You are here: nested loop, 2 MySQL tables « PHP Programming Language « IT news, forums, messages
nested loop, 2 MySQL tables

Posted by Chris on 06/14/06 17:25

I have a set of nested links, and at one time each category one had all the
same subcategories. Now that has changed - each category has different
subcategories. I have a tree menu, but now it just shows all subs under
each category, of course. I have 2 tables - one for categories, one for
subcategories - they are related by the categoryID. I think I have the SQL
fine (have tried several different versions - see most recent/uncluttered
below), but how do I get it to work correctly in the tree loop?

SELECT DISTINCT cat.catName, cat.catDesc, subcat.subcatName
FROM cat, subcat
WHERE cat.catID = subcat.catID;

Tree example:
cat.catName(1)
subcat.subcatName(1)
subcat.subcatName(2)

cat.catName(2)
subcat.subcatName(3)
subcat.subcatName(4)


I'm sure it must be simple, and I'm just having a slow brain day...

Thanks,
Chris

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация