Now I would like to hold the 2nd selected value, have it search the database find all that match the selected and then only display what matches it in the corresponding ROWS in the database.
I have no issue passing one value to another dropdown box thats easy plus I am using ajax could some one help me write an array to HOLD the selected value and then only find the information attached to that value.
Here is the code I was trying. The code starts at the getpart command
Code: Select all
// =====================================================================================================
// Construct parts overview after user selected state, city.
// =====================================================================================================
if( (isset($_GET['getpart']) AND isset($_GET['state']) AND isset($_GET['city']))
OR (isset($_GET['search']) ) ) {
if(isset($_GET['getpart'])) {
$st = $_GET['state'];
$ci = $_GET['city'];
$query="SELECT dealerlocater.state, ".
" dealerlocater.company, dealerlocater.address, dealerlocater.city, dealerlocater.stateabb, dealerlocater.zip, dealerlocater.phone, dealerlocater.web ".
" FROM dealerlocater ".
" WHERE state='$st' ".
" GROUP BY dealerlocater.state ".
" ORDER BY dealerlocater.state ";
}
$res = mysql_query($query)
or die("Invalid query: " . mysql_query());
// verify that the part number has been passed
if (!isset($_REQUEST['city']) OR strlen(trim(strip_tags($_REQUEST['city']))) < 4 )
die("Invalid city specified.");
// sanitize and save the requested part number
$city = trim(strip_tags($_REQUEST['city']));
// select the data row for the specified part number
$res = mysql_query("SELECT * FROM dealerlocater WHERE city='$city' LIMIT 1")
or die("Invalid select query: " . mysql_query());
// verify that a row has been selected, if not: issue message
if (mysql_num_rows($res) < 1)
echo "No database information for '$city' found.";
// a row had been selected, process the data
else {
$row = mysql_fetch_assoc($res);
$city = $row['city'];
$st = $row['state'];
echo $city;
?>