Colin Posted January 30, 2004 Share Posted January 30, 2004 hey guys.. I have found code elsewhere on the site that will suit my purpose (I believe). It is a script that will allow me to have three pulldown boxes for a vehicle (year/model/make). My problem is that when I select a year, it adds vehicle_model_year to the site's URL.. That's all fine and dandy. When I then select a make (Chevrolet), the URL then removes the vehicle_model_year and replaces it with vehicle_model_make.. Here's the code that makes up my /includes/boxes/vehicle_search.php <?php ?> <!-- vehicle_search //--> <tr> <td> <?php $info_box_contents = array(); $info_box_contents[] = array('align' => 'left', 'text' => "Vehicle Search"); new infoBoxHeading($info_box_contents, false, false); $vehicle_query = tep_db_query("select vehicle_year_id, vehicle_year from " . vehicle_years . " order by vehicle_year_id"); // Display drop-down 1 $select_box = '<select name="vehicle_year_id" onChange="this.form.submit();" size="' . MAX_YEARS_LIST . '" style="width: 100%">'; if (MAX_YEARS_LIST < 2) { $select_box .= '<option value="">' . 'Vehicle Year' . '</option>'; } while ($years_values = tep_db_fetch_array($vehicle_query)) { $select_box .= '<option value="' . $years_values['vehicle_year_id'] . '"'; if ($HTTP_GET_VARS['vehicle_year_id'] == $years_values['vehicle_year_id']) $select_box .= ' SELECTED'; $select_box .= '>' . $years_values['vehicle_year'] . '</option>'; } $select_box .= "</select>"; $select_box .= tep_hide_session_id(); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form name="vehicleyears" method="get" action="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '">', 'align' => 'left', 'text' => $select_box); new infoBox($info_box_contents); $vehicle_make_query = tep_db_query("select vehicle_make_id, vehicle_make from " . vehicle_make . " order by vehicle_make"); // Display drop-down 2 $select_box1 = '<select name="vehicle_make_id" onChange="this.form.submit(); " size="' . MAX_MAKES_LIST . '" style="width: 100%">'; if (MAX_MAKES_LIST < 2) { $select_box1 .= '<option value="">' . 'Vehicle Make' . '</option>'; } while ($make_values = tep_db_fetch_array($vehicle_make_query)) { $select_box1 .= '<option value="' . $make_values['vehicle_make_id'] . '"'; if ($HTTP_GET_VARS['vehicle_make_id'] == $make_values['vehicle_make_id']) { $select_box1 .= ' SELECTED'; $make_id = $make_values['vehicle_make_id']; } $select_box1 .= '>' . $make_values['vehicle_make'] . '</option>'; } $select_box1 .= "</select>"; $select_box1 .= tep_hide_session_id(); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form name="vehiclemake" method="get" action="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '">', 'align' => 'left', 'text' => $select_box1); new infoBox($info_box_contents); if ($make_id != $make_values['vehicle_make_id']) { $vehicle_model_query = tep_db_query("select vehicle_model_id, vehicle_model from " . vehicle_model . " where vehicle_make_id = " . $make_id); } else { $vehicle_model_query = tep_db_query("select vehicle_model_id, vehicle_model from " . vehicle_model . " order by vehicle_model"); } // Display drop-down 3 $select_box2 = '<select name="vehicle_model_id" onChange="this.form.submit();" size="' . MAX_MODELS_LIST . '" style="width: 100%">'; if (MAX_MODELS_LIST < 2) { $select_box2 .= '<option value="">' . 'Vehicle Model' . '</option>'; } while ($model_values = tep_db_fetch_array($vehicle_model_query)) { $select_box2 .= '<option value="' . $model_values['vehicle_model_id'] . '"'; if ($HTTP_GET_VARS['vehicle_model_id'] == $model_values['vehicle_model_id']) $select_box2 .= ' SELECTED'; $select_box2 .= '>' . $model_values['vehicle_model'] . '</option>'; } $select_box2 .= "</select>"; $select_box2 .= tep_hide_session_id(); $info_box_contents = array(); $info_box_contents[] = array('form' => '<form name="vehiclemodel" method="get" action="' . tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false) . '">', 'align' => 'left', 'text' => $select_box2); new infoBox($info_box_contents); ?> </td> </tr> <!-- vehicle_search_eof //--> Here's the modified HTML_GET_VARS area under the filterlist section in /index.php $filterlist_sql = "select distinct c.categories_id as id, cd.categories_name as name from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c, " . TABLE_CATEGORIES . " c, " . TABLE_VEHICLE_MAKE . " vma, " . TABLE_VEHICLE_YEAR . " vyr, " . TABLE_VEHICLE_MODEL . " vmd, " . TABLE_CATEGORIES_DESCRIPTION . " cd where p.products_status = '1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p2c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "' and p.manufacturers_id = '" . (int)$HTTP_GET_VARS['manufacturers_id'] . "' and vma.vehicle_make_id = '" . (int)$HTTP_GET_VARS['vehicle_make_id'] . "' and vmd.vehicle_model_id = '" . (int)$HTTP_GET_VARS['vehicle_model_id'] . "' and vyr.vehicle_year_id = '" . (int)$HTTP_GET_VARS['vehicle_year_id'] . "' order by cd.categories_name"; Is there something I'm doing wrong? And how can I have the script have subcategories so that when you choose the make (Chevrolet) you do not get Ford vehicles under the model pulldown? Thanks! Colin Link to comment Share on other sites More sharing options...
Colin Posted January 31, 2004 Author Share Posted January 31, 2004 Does anyone have any input for me? Getting this running nicely would be a major help :) Link to comment Share on other sites More sharing options...
thrasha Posted April 23, 2004 Share Posted April 23, 2004 Your post was one of the posts that helped me get to this point... B) View MY Post Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.