![]() |
My dynamic menu
Hi there!
I have written a dynamic menu. In one tabel I have the titles of the menu. Ex: Home & shop etc. In another table I have the subtitles. Ex: When you click on shop, all the subtitles connected to shop should appear right underneath the title. Like this: Home Shop(active) Good shop Medium Shop Bad shop Contact I think you understand. I connect those subtitles and titles with a id_parent, so all subtitles have the same id_parent as their respective title. But instead of the subtitles just appearing right under its title, it appears under every title in the menu. It extracts the right subtitles from the database, but print them under all titles. I think the problem lies in, how the udskriv_menu(); is chosen, but I do not know how to solve it... Here is my title: php Code:
php Code:
|
Oops. I didnt see this "post code" function. Should I post me code in such one?
|
I can't see a reason why you couldn't.
Advice: In the future, try to separate the HTML from the PHP as much as possible. Don't embed large blocks of html into echo/print statements. It's hard to read/debug and especially hard to change the presentation if you needed to do so. |
Quote:
What happens is that when a title is "clicked", the menu is shown like this: Home Good shop medium shop bad shop Shop Good shop medium shop bad shop And this should only be under shop. |
I meant shouldn't.
Now, for the problem. I don't really understand what you're trying to pull there, but here's an idea of what it should look like: PHP Code:
|
Nice. Except it does not do the $subcategory
|
woot?
Of course, if you needed limitless categories and subs, you would write a recursive function to do just that. Or use the MySQL way, as pointed out around here somewhere (nice approach, btw). |
Can you show with some code?
|
| All times are GMT. The time now is 09:22 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0