Jump to content

Overly Complicated..?


NerdConcepts

Recommended Posts

Yes, I am back. I've been searching for hours trying to find a solution to my problem. I want to make sure I am not overly complicating things with what I am trying to do.

 

Scenario: Being able to add a Business and their information to the database, while being able to categorize and sub-categorize them.

Example: Company1 would be under Category: 'automotive' then under Sub-Category: 'Performance'.

 

Seemed easy at first, until I was writing the code for the forms to add the business. I can easily make the dynamic drop down menu to select the category that the business would go into. Problem I am having is that the person adding the business isn't able to select a sub-category based on the main category. I have 3 database tables to do all of this. 1 for the Business info, 1 for the Categories and 1 for the Sub-Categories. My main question is: can you make it where if you select (example) 'Automotive' from the main categories menu then have the Sub-Categories menu reflect the 'Automotive' sub-categories? I was thinking about creating a few pages where you first select the category, then it moves you to another page for the sub-category then onto the actual business add page. But that just seems like it is overly complicating things, since I would have to transfer information form page to page. I've seen this done on websites like DeviantArt (when you select a category, etc for your art) or ATI for picking drivers, etc etc.

 

Sorry for taking up so much of the form helper(s) time, but I am tired of looking and need to show some progress or I am going to go nuts sitting here and it's hard to get sleep when this is all I can think of, lol. Thanks again for everyone(s) help in the past. This time I am not making to much of a stupid mistake.

Link to comment
https://forums.phpfreaks.com/topic/40824-overly-complicated/
Share on other sites

there are 2 things you can do

 

first:

you can submit the form to same page when you select a category and query the database to get the subcategories from database and fill the select box of subcategories...

 

Second:

you can use ajax when you select a category and get the subcategories to fill the subcategories select box

Link to comment
https://forums.phpfreaks.com/topic/40824-overly-complicated/#findComment-197656
Share on other sites

Thanks. I'll have to play around with both of those. Just let me make sure I fully understand.

 

Category 'Automotive' has an id of '1' ...

Sub-Category 'Performance' has an id of '1' also (two different databases).

 

Now, when I do all of this I should create both the category and sub-category ids in the business info table? That away I can view ALL the business related to Automotive or if I want I can view all those related to Automotive/Performance.

 

The first suggestion seems like something I will end up going with. Since I will never have to change the main Category for a Business, maybe will have to change the sub-category which I can just make an edit page to do that, which is no problem..done it for users already.

Link to comment
https://forums.phpfreaks.com/topic/40824-overly-complicated/#findComment-197657
Share on other sites

Ok, I now have a page that allows you to either add a Category or Sub-Category. This works just fine and I have put some categories and sub-categories into my database. The sub-categories db table also has a the main categories id in it. This way I am able to do references. Like "SELECT sub_id, sub_title, main_id FROM cat_sub WHERE main_id='$mid'" and $mid is given when you first start to search for a business list. You select the category and it shows all the business in that category BUT also allows you to then select a sub-category. Which the query above should do just that. So, I think I have figured out how to do this. I am looking in AJAX more to see how to do the partial page refresh stuff so everything to add a new Business can be on one page and you don't have to submit more then once. I just am clueless when it comes to javascript...never used it before.

Link to comment
https://forums.phpfreaks.com/topic/40824-overly-complicated/#findComment-198067
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.