How could I build a unique array check each of the address fields.
E.g at the moment I get everything:
$stmnt = "SELECT `location_id`, `location_address1`, `location_address2`,
`location_town`, `location_region`, `location_postcode`
FROM locations WHERE user_id = '{$id}'";
$results = $db->fetchAll($stmnt);
if(!empty($results )) {
foreach($results as $row) {
if($unique){
$value = $row['location_id'];
$label = implode(", ", array(
'address1' => $row['location_address1'],
'address2' => $row['location_address2'],
'town' => $row['location_town'],
'region' => $row['location_region'],
'postcode' => $row['location_postcode']
));
}
I was thinking that where if($unique){ is you would check this address1, address2, etc exist in the temp array by searching this some how?
Using SELECT DISTINCT will allow you to bring back a unique set of results, excluding results that are dupliciates of another. You can even still use the ORDER BY if you intend to, but remember that with a DISTINCT selection, anything in the ORDER BY must also be in the SELECT statement.