The city_id and state_id, along with name, phone number, address…etc are in one table in the database and the cities listed with names and ids are in another.
Here is the code for the search-results.php:
[php]
Select City
<?php
$result = @mysql_query("SELECT * FROM bk_city");
while ($city=mysql_fetch_array($result)){
?>
selected <?php } ?> ><?php echo $city['name']; ?>
<?php } ?>
<input type="submit" value="Go" id="locSearch" />
</form>
<?php
if($_GET['criteria']=='city'){
$sql_get_store = "SELECT * FROM bk_stores WHERE city_id = '$_GET[city]' ORDER BY `bk_stores`.`city` ASC";
$result_get_store = @mysql_query($sql_get_store);
}elseif($_GET['address']=='' && $_GET['city']!=='' && $_GET['zip']=='' && $_GET['state']=''){
$sql_get_store = "SELECT * FROM bk_stores WHERE city_id = '$_GET[city]' ORDER BY `bk_stores`.`city` ASC";
$result_get_store = @mysql_query($sql_get_store);
}else{
$sql_get_store = "SELECT * FROM bk_stores WHERE ( address LIKE '%$_GET[address]' AND zip LIKE '%$_GET[zip]' AND city LIKE '%$_GET[city]' ) ORDER BY `bk_stores`.`city` ASC";
$result_get_store = @mysql_query($sql_get_store);
}
?>
<?php
if(mysql_num_rows($result_get_store)==0 && $_REQUEST['state']=='5'){
?>
Tommy Carter for management opportunities!.
<?
}elseif(mysql_num_rows($result_get_store)==0){ ?>
No match found.
<?php
}else{
while($row_get_store=mysql_fetch_array($result_get_store)){ ?>
<?php echo $row_get_store['store'];?>
<?php echo $row_get_store['city'];?>
<?php echo $row_get_store['address']; ?>
<?php echo $row_get_store['city']; ?>,
<?php
if($row_get_store['city_id']==1){
echo 'TX';
}elseif($row_get_store['city_id']==2){
echo 'TX';
}elseif($row_get_store['city_id']==3){
echo 'Test';
}
?>
<?php echo $row_get_store['zip']; ?>
<?php echo $row_get_store['phone'];?>
<?php
}
}
?> [/php]