Jump to content

Recommended Posts

hi,

After goin thru many lot of links on internet, i have come up here.

I am new to php and am trying to make a left navigational menu in php thru mysql data.

I have recipe data, which needs to be displayed category wise, then name wise and clicking on name recipe shud come up.

Appetizers (Category)

        ABC(Name)

Can anybody help me to create a dynamic menu???

Also while searching on the net, the solution i inferred is that Category and name fields should be made in one column and their should be parent id (for root 0, first level 1 ...)if this is the solution, then is there any method to convert this table ('id', 'Category', 'Name', 'Recipe') to ('id', 'Name'(name + category), 'parentid')

ur help wud be really appreciated!!

 

 

Link to comment
https://forums.phpfreaks.com/topic/168766-dynamic-menu-data-from-mysql-with-php/
Share on other sites

The database table is : create table 'Recipe' ('Auto' int(10) default 0, 'Category' VARCHAR(255) default null, 'Name' VARCHAR (255) default null, Recipe Text ) TYPE = MYISAM;

 

I want to create a menu which is order by Category selecting the Category related recipe Name should be populated. something like this

 

I wud really appreciate ur help

I wasn't able to run the query the quotes needed to be removed.

I indented the create query so it's more readable and you might have a better response in the future

create table Recipe (
  Auto int(10) default 0,
  Category VARCHAR(255) default null,
  Name VARCHAR (255) default null,
  Recipe Text
) ENGINE = MYISAM;

 

I have a bit of critique here on your table.

1. Why is your first field named auto??? shouldn't this be id or something similar.

2. You have category as text i'd create a different table for categories and set a relation with a foreign key

3. You have a field recipe in your table recipe. Maybe you should just name this field description so it's less confusing.

 

My Category field is not that big it is VARCHAR (20).

It is not the reason why I say you are better of using a different table for categories. You might want to change a category name in the future. With the current database design you would have to manually rename all of the category names instead of doing it only once.

 

Besides that you might want to fit a category in a category as in use subcategories.

 

 

Please let me know how to go for creating dynamic menu

What code do you have so far for selecting the results from the database? Are you using PHP?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.