oaklinedesign Posted October 9, 2010 Share Posted October 9, 2010 Hey, I'm obviously new here. I some php knowledge, but not very much MySQL knowledge. Any help would be hugely appreciated. Perhaps even a trade of some graphic design work for some help making this come to reality. I have a client who would like to use multiple dropdown list to narrow a selection of items to just a two or three. There are approximately 80 items right now, each with 5 different attribute. We would like it so that each time you select from one dropdown an attribute the next dropdown dynamically changes and only shows attributes that relate to the remaining item. Example DropDown1 is the Continent (North America, Asia, etc), DropDown2 contains a list of the countries, DropDown3 contains a list of the providences/states/regions, DropDown4 contains a list of the cities. Once the all the preceding lists are chosen the user is then shown in plain text a list of the Stores in that city. Thats not actually what we need narrowed down, so the database/tables wont actually be containing every city in the world—as I said only 80 items. What do you think would be the best way to do this? Would using an xml or javascript table be easier than using mySQL and PHP? Do you know any tutorials on how this might be done. I've seen things that show 2 levels of dropdowns, but not 5 or 6 (as I need). Please, please, please, please help. Quote Link to comment Share on other sites More sharing options...
Stephen68 Posted October 9, 2010 Share Posted October 9, 2010 Not to sure how to do this but it looks like you could use some ajax, which I know nothing about really. You could use an i-frame as well maybe, I'm new as well. You could have one drop down box show in the page in an i-frame with your choices, once they pick one you have it refresh the frame. Using the choice they made you query your DB and make the second drop down box form that info. Not sure if this is right way to go about it but it's where I would likely start, again I'm new to this as well.. Stephen Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 9, 2010 Share Posted October 9, 2010 You had it with ajax but definitely not with iframes as they are deprecated, or just not used, I'm pretty sure. I could help code this but I am not really looking to get anything designed and as this is a help forum I can't do it all for you. Quote Link to comment Share on other sites More sharing options...
ram4nd Posted October 9, 2010 Share Posted October 9, 2010 You had it with ajax but definitely not with iframes as they are deprecated, or just not used, I'm pretty sure. I could help code this but I am not really looking to get anything designed and as this is a help forum I can't do it all for you. What would you use instead of iframes then? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted October 10, 2010 Share Posted October 10, 2010 What would you use instead of iframes then? Just php, mysql, and javascript. Quote Link to comment Share on other sites More sharing options...
ram4nd Posted October 10, 2010 Share Posted October 10, 2010 And if the page is from other domain? Quote Link to comment Share on other sites More sharing options...
chmpdog Posted October 11, 2010 Share Posted October 11, 2010 And if the page is from other domain? link to it? Iframes are generally bad practice since you cannot be accountable for content Quote Link to comment Share on other sites More sharing options...
ram4nd Posted October 11, 2010 Share Posted October 11, 2010 And if the page is from other domain? link to it? Iframes are generally bad practice since you cannot be accountable for content but this way I lose a "customer" Quote Link to comment Share on other sites More sharing options...
DarkMantis Posted October 11, 2010 Share Posted October 11, 2010 Why not use templated HTML for the drop down lists, then you don't have to worry about re-writing them etc. And for everytime they get set, create a new drop down using the template and get the data from a mysql db, replace the templated tags with the data from the database and repeat. Here is a good example of a template class: http://www.phpro.org/classes/Template-Class.html Template: <select name="{tpl.SelectName}"> <option name="{tpl.Option"}>{tpl.OptionValue}</option> </select> ------------------------------ $this->tplSet('tpl.SelectName') = mysql_result(mysql_query("SELECT * FROM `someTable` WHERE 1=1")); $this->tplReplaceAll(); Then using Ajax/Javascript repeat it all and create a new drop down box using the results for the search query. Sorry if that doesn't make too much sense, It's early! lol. Hope this helped! Quote Link to comment Share on other sites More sharing options...
Pawn Posted October 11, 2010 Share Posted October 11, 2010 I don't see what iframes or template classes have to do with anything the OP asked. The simplest way to accomplish this would be to pass selections in the querystring, using a Javascript onclick to refresh the page, narrowing the options in subsequent dropdowns where $_GET['value_of_first_dropdown'] is set. To avoid refreshing the page, I'd suggest using jQuery to easily repopulate your dropdown menus from a simple PHP page loaded asynchronously. In either case, you'll want to store all the options in a MySQL database table. Good luck. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.