josh140 Posted March 12, 2007 Share Posted March 12, 2007 Hi, Im looking at using two drop down boxes one which will hold a selection of values and then depending on those values i want the second drop down box to be filled by a query from the database for example. In the first drop down box i select search by type and then in the second I want all the types from the product type table to be listed! The user will then select the type they want to search for and a query is run and the results returned for every record that the specified type is used. Any suggestions: Im new to oracle and php so go easy on me! Thanks Link to comment https://forums.phpfreaks.com/topic/42404-using-drop-down-boxes-connected-to-oracle/ Share on other sites More sharing options...
Feenix566 Posted July 3, 2007 Share Posted July 3, 2007 You could use AJAX to populate the second dropdown box dynamically, but I don't think you're looking for a solution that sophisticated. Instead, try this: Make a form that submits to itself, and make the PHP script that creates the form check to see if the variable from the first dropdown box was submitted with the request. <form name='theform'> <select name='type' onChange='document.theform.submit()'> <? $DB = oci_connect("user", "pswd", "db"); $get_types = OCIParse($DB, "select distinct type from product"); OCIExecute($get_types); while($type = oci_fetch_array($get_types)) echo "<option value='{$type['TYPE']}' " . ((isset($_GET['type']) && $_GET['type'] == $type['TYPE']) ? "selected" : "") . ">{$type['TYPE']}</option>\n"; OCIFreeStatement($get_types); ?> </select> <p> <? if(isset($_GET['type'])){ echo "<select name='product'>\n"; $get_products = OCIParse($DB, "select product from product where type = :type"); ocibindbynname($get_products, ":type", $_GET['type']); OCIExecute($get_products); while($product = oci_fetch_array($get_products)) echo "<option value='{$product['PRODUCT']}'>{$product['PRODUCT']}</option>\n": OCIFreeStatement($get_products); echo "</select>"; } ?> <input type=submit> </form> Link to comment https://forums.phpfreaks.com/topic/42404-using-drop-down-boxes-connected-to-oracle/#findComment-288902 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.