Jump to content

Dropdown Menu from SQL Query Results (Auto makes models)


jessicahanna214

Recommended Posts

Hello im pretty new at this and am losing my mind. i have found and tried a lot of the "codes"  etc out there with no luck.

 

This will be for an "auto/car search" All the makes/models/prices etc loaded into this form along with zipcodes. Here is the form

 

<form id="SearchForm3" action="">
                                       <div>
                                          <label><strong>Make</strong><br />
                                             <select name="makers">
                                                <option>All Makers</option>
                                                <option>nissan</option>
                                             </select>
                                          </label>
                                         <label><strong>Model</strong><br />
                                          </label>
                                          <label><strong>Maximum P
                                            <select name="model">
                                              <option>All Models</option>
                                              <option>750</option>
                                           </select>
                                           rice</strong><br />
                                             <select name="price">
                                                <option>Any</option>
                                                <option>20000</option>
                                             </select>
                                          </label>
                                          <div class="container">
                                          <label class="left"><strong>Search Within</strong><br />
                                             <select name="search" class="miles">
                                                <option>50 miles</option>
                                                <option>10 miles</option>
                                             </select><em>of</em>
                                          </label>
                                          <label class="zip"><strong>ZIP</strong><br /><input type="text" value="" class="input"  /></label>
                                         </div>
                                       </div>
                                       <div class="alignright">
                                          <a href="#" class="link" onclick="document.getElementById('SearchForm').submit()"><strong><strong>search new</strong></strong></a>
                                       </div>
                                    </form>

 

So i need to put these query results in

<?php
   include ("inc/config.php") ;

$sql="  SELECT DISTINCT modelYear, divID, divName, modelName, modelDivID
   FROM chrome_divisions, chrome_models
   WHERE modelDivID = divID
   AND modelYear = 2011
   AND divID = '$Make'
   AND modelName = '$Model'
   GROUP BY modelYear, divName, modelName;
"; 


$sql="SELECT LogMonth, LogYear FROM Student_MLog WHERE Student_ID='$username'"; 

$result=mysql_query($sql); 


while ($row=mysql_fetch_array($result)) { 

    $modelYear=$row["Year"]; 
   $divName=$row["Make"]; 
   $modelName=$row["Model"]; 

echo "<option>$divName<option/>";
} 
echo "<select/>";


?>

 

So once someone clicks "Nissan" Then only nissan models will pull up. Or Chevrolet and only chevy results pull up. From what i understand is that i might need to use AJAX or Java which i cant figure out yet. Anyhelp please!!!!!!!!!

Link to comment
Share on other sites

Hi

 

Downloading ALL the makes, models, prices and zip codes is likely to be a lot of data (making the page slow).

 

I would suggest just getting the makes, and when that changes you use javascript for an AJAX call to get the matching list of models for that make (and once the model is selected you go and get a list of those for sale and their prices).

 

All the best

 

keith

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.