$value) { $arrayOfArrays[$key] = "'" . serialize($value) . "'"; } $arrayOfArrays = array_unique($arrayOfArrays); foreach ($arrayOfArrays as $key=>$value) { $arrayOfArrays[$key] = unserialize(trim($value, "'")); } return $arrayOfArrays; } if(!empty($_GET["state"])) { $smarty->assign("get_state", $_GET["state"]); // * show a particular state's dropdown of cities, then stores within a chosen city $theState = strtolower($_GET["state"]); $statename_sql = "SELECT statename FROM states_data WHERE LOWER(stateabbrev) = '".$theState."'"; $statename_result = func_query($statename_sql); if (!empty($statename_result)) foreach ($statename_result as $row) $state_names[] = $row["statename"]; $smarty->assign("state_names", $state_names); $cities_sql = "SELECT DISTINCT t1.city FROM stores AS t1, states_data AS t2 WHERE LOWER(t2.stateabbrev) = '".$theState."' AND LOWER(t1.state) = LOWER(t2.stateabbrev) ORDER BY t1.city"; $cities_result = func_query($cities_sql); $cities_result = my_array_unique($cities_result); if (count($cities_result) > 1) { foreach ($cities_result as $row) if (!empty($row["city"])) $cities[] = $row["city"]; $smarty->assign("cities", $cities); } else { $row = array_pop($cities_result); $_GET["city"] = $row["city"]; } $smarty->assign("get_city", $_GET["city"]); $stores_sql = "SELECT t1.*, t2.statename FROM stores AS t1, states_data AS t2 WHERE LOWER(t2.stateabbrev) = '".$theState."' AND LOWER(t1.state) = LOWER(t2.stateabbrev) AND (t1.city = '".$_GET["city"]."' OR t1.city = '') ORDER BY t1.name"; $stores_result = func_query($stores_sql); if(!empty($stores_result)) { $stores = array(); foreach ($stores_result as $row) { $store = array("id"=>$row["id"],"name"=>$row["name"],"address1"=>$row["address1"],"address2"=>$row["address2"],"city"=>$row["city"],"state"=>$row["state"],"zip"=>$row["zip"],"statename"=>$row["statename"],"phone"=>$row["phone"],"fax"=>$row["fax"],"url"=>$row["url"]); $stores[] = $store; } $smarty->assign("stores", $stores); } } else { // * dropdown for states with stores $stores_sql = "SELECT DISTINCT t1.state, t2.statename FROM stores AS t1, states_data AS t2 WHERE LOWER(t1.state) = LOWER(t2.stateabbrev) ORDER BY t1.state,t1.id"; $stores_result = func_query($stores_sql); $stores_result = my_array_unique($stores_result); $states = array(); foreach ($stores_result as $row) $states[] = array("state"=>$row["state"],"statename"=>$row["statename"]); $smarty->assign("states", $states); } $location[] = array("Stores",""); # Assign the current location line $smarty->assign("location", $location); $smarty->assign("main","store_finder"); func_display("customer/home.tpl", $smarty); ?>