rostros Posted July 28, 2006 Share Posted July 28, 2006 Ive been using Dreamweaver for a while now and have been building dynamic sites with PHP / MySQL which is great fun but recently i have hit a break wall on a latest development. This is the current issue where im stuck , In one table which contains these details ---------------------------------vehicle_idvehicle_manufacturervehicle_model vehicle_added----------------------------------On my .PHP Page I have created a Form, with a List Box and created connection via MySQL to call all the Vehicles in this list.Problem : The List Box only contains either Manufacturer or Model Type not both at once, so I created another List Box in the Form so when the user selects the vehicle manufacturer it then filters the model dropdown box depending on the manufacturer. I know there is way of using javascript to filter the options on selection but i wish to use the options stored in MySQL. How do you program this Drop Down Box's that use MySQL Data, and how do you Filter them ? would you use $URL Variables or $FORM Variables or something different. Any help would be great. Link to comment https://forums.phpfreaks.com/topic/15893-semi-amateur-requesting-help-on-mysql-php/ Share on other sites More sharing options...
tomfmason Posted July 28, 2006 Share Posted July 28, 2006 ok I am not sure exactly what you meant. But here is what I would do if I wanted a dropdown box with the vehicle_manufacturer vehicle_model in it.[code=php:0]<select size="20" name="whatever"><?php$sql ="SELECT vechicle_manufacturer, vehicle_model FROM your_table";$get_vechicles = mysql_query($sql);if (!get_vechicles) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit;}if (mysql_num_rows($get_vechicles) == 0) { echo "There are no vechicles in the database"; exit;}while ($row = mysql_fetch_assoc($get_vechicles)) { echo '<option>' . $row['vechicle_model'] . ' ' . $row['vechicle_manufacturer'] .'</option>';}mysql_free_result($get_vechicles);?></select>[/code]Hope this helps,TOM Link to comment https://forums.phpfreaks.com/topic/15893-semi-amateur-requesting-help-on-mysql-php/#findComment-65280 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.