Jump to content

PHP Navigation For CMS


scraptoft

Recommended Posts

I am trying to create a navigation bar which will echo all of the categories in the database.

I want the navigation bar to show like below:

Category1
-subcategory
-subcategory
-subcategory
Category2
-subcategory
-subcategory
Category3
-subcategory
-subcategory
-subcategory
-subcategory

Heres my code to query Category:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]$query_category = "SELECT name FROM webstructure where level = '2'";
$result_level = mysql_query($query_category)
or die("Invalid query: " . mysql_error());
while ($row=mysql_fetch_array($result_lcategory2)) {
$name = $row['name'];[/quote]

This echos like:
Category1
Category2
Category3

I cannot figure out how to echo the correct [b]Subcategory[/b] underneath it's speficific [b]Category[/b]. Does anyone have any ideas how to do this, or what functions to use?

Thankyou for your time
Link to comment
https://forums.phpfreaks.com/topic/12601-php-navigation-for-cms/
Share on other sites

My category table is like so.

Name [name of category or subcategory]
parent_category [if its a subcategory the parent name is here]
level ['1','2','3'] [different levels to show on each page]

After writing this out, i'm starting to think I need to make changes to my table. Or can I get away with it this way?

Cheers for your fast reply.
Link to comment
https://forums.phpfreaks.com/topic/12601-php-navigation-for-cms/#findComment-48317
Share on other sites

I'm still trying to learn PHP but could do with this project finished (it doesn't have to be perfect) so I can get onto studying the language more. Could you give me a few pointers on how I could get away with it.

p.s thanks for the tutorial I will deffinatly read it more indepth in the morning.
Link to comment
https://forums.phpfreaks.com/topic/12601-php-navigation-for-cms/#findComment-48327
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.