Forum Moderators: coopster
My client wants to display different regions and for the search to find a county/city/town to that region.
Example:
The user inputs
Title: Assistant
Salary (Min): £13,000
Salary (Max): £25,000
Location: South-west
and the results should be everything within the south-west area
I am using MySQL.
Many Thanks
The next best option is to store data by State and possibly city, many searchers will want to specify one and/or both in any search.
Just my 2 cents but "South West" may be too vague. If it's a must to go with SW you'll want to set up a SW table, along with a NW, NE and SE table, and have results search only the appropriate table.
I can't provide code without seeing what you have in place.
table jobs
id¦title¦salary¦city¦province¦region
table regions
id¦region
table cities
id¦title¦province¦region
Might even need provinces too, to fully normalize. The regions, cities, etc. are all stored in the jobs table by ID as integers:
table jobs
id¦title¦salary¦city¦province¦region
1¦Head Janitor¦25000¦123¦45
so your region select list would be like
...
<option value="45">South West</option>
...
$where=NULL;
if (isset($_POST['region']) and ($_POST['region'] > 0)) {
if ($where) { $where .= ' and'; }
$where .= " region=" . $_POST['region'];
}
}
$query = "select * from jobs";
if ($where) { $select .= " where $where"; }
The other solution is as mentioned, use some connection to say, the G. maps API to get what you're looking for, but this makes it unreliable on a couple points: it's an external service, and is largely driven by Javascript.