turpentyne Posted August 13, 2012 Share Posted August 13, 2012 Ok... I'm starting from scratch. I know there's an easier way to do what I want to do, but I dove in head-first with an empty pool of knowledge on this apparently. So, starting from the beginning, how would I go about doing this. I think it's probably easier than I've made it. Everything about my current code is broken/ inneficent. I want to build a page where t customer builds their own product from different components. After they choose option A1 or A2, the page reloads, or a div shows that lists the B options available to what they picked, after that, they get the C choice they made. And so on. As they make each choice in the form, I also want to give them a running list of their choices to the side: I.E. "you have chosen: A: 2, B: 5, C: 1, etc. I have three main tables that they're working from: 1. component_categories: the different categories of items - essentially A, B, C, D as shown above. 2. Components: the 1 or 2 or 3, etcetera. 3. I also have a many-to-many link table, components_to_components, that lists the component id, and then the compatible component id. for example: A1 is compatible with B2 A1 is compatible with B4 A2 is compatible with B2 A2 is compatible with B3 B2 is compatible with C3 and so on. A loose outline, anything would help. I can post what I have right now, but it's such a confusing mess and I'd really like to start over from scratch with the simplest, most elegant solution, so I know how to do this for the future. How would you build such a section? Quote Link to comment https://forums.phpfreaks.com/topic/267022-need-some-redirection-on-a-build-it-form/ Share on other sites More sharing options...
Christian F. Posted August 14, 2012 Share Posted August 14, 2012 If I were you, and knowing loosely what you want, I think I'd do it in a manner similar to this one: // Check if something has been posted. if (!empty ($_POST)) { // Validate options selected, and return an associative array with the selections. $selected = fetch_options ($_POST); // Retrieve the available options, based upon what's previously selected. $available = $db->query ('SELECT * WHERE $selected'); // Create a drop-down list for each category, from the results of the query. // Last parameter is used to set the default value, if something has been selected. create_dropdown ('option_list_1', $available['options_1'], $selected['option_1']); create_dropdown ('option_list_2', $available['options_2'], $selected['option_2']); create_dropdown ('option_list_3', $available['options_3'], $selected['option_3']); // Add the breadcrumb trail for the selection. $template->addCrumb ($selected); // Create the DIV with the finished product details. $template->addProduct ($selected); } // Show the form with the drop-down lists. $template->showForm (); Should give you something to think about, at least. Sorry about the long reply time, by the way. Your question is quite expansive and rather open ended, so needed to mull it over a bit. Quote Link to comment https://forums.phpfreaks.com/topic/267022-need-some-redirection-on-a-build-it-form/#findComment-1369388 Share on other sites More sharing options...
turpentyne Posted August 14, 2012 Author Share Posted August 14, 2012 No worries, on the delay! I spent a little time last night looking into how to set up classes and functions, so this looks like it's working off of what I was researching. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/267022-need-some-redirection-on-a-build-it-form/#findComment-1369448 Share on other sites More sharing options...
Christian F. Posted August 14, 2012 Share Posted August 14, 2012 You're welcome. Quote Link to comment https://forums.phpfreaks.com/topic/267022-need-some-redirection-on-a-build-it-form/#findComment-1369458 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.