Hello.
I have been trying to accomplish this for since 10:00 this morning and just cannot work it out. I have 3000 UK postcodes in a mysql database containing the first 3/4 digits of a UK postcode i.e. CT1, CT2, CT3 (this also contains longitude and latitude, but ignore that for now as it calculates distance using the first 3/4 digits of the post code OK already).
Users use their full post code i.e. CT1 1AD when logging items and other users search using full post codes for users items but the issue is, the database only contains the first 3/4 digits (I have tested logging items with just 3/4 digits and then searching for the items with the first 3/4 digits and the script works and calculates the distance in miles).
I was wondering if anyone could help me alter the script to it only needs to match the first 3/4 digits in a full post code to return a result, currently is will only match if any user uses the first 3/4 digits such as CT1. The code I am using which I think needs to be altered is:
// radius ...
$i = 0;
$sql_query = "SELECT * FROM setup_radius ORDER BY radius_order ASC, radius_name ASC";
$result = mysql_query($sql_query) or die(mysql_error());
while($row = mysql_fetch_array($result)){
$radius_id = $row[radius_id];
$radius_name = $row[radius_name];
$arr_radius_id[$i] = $radius_id;
$arr_radius_name[$i] = $radius_name;
$arr_radius_status[$i] = "no";
if ($radius_id == $sradius) { $arr_radius_status[$i] = "yes"; }
$i++;
}
Please help me and I can provide more of the script if required, thanks.