Proximity search of related table

By Toledoh - April 2, 2017

Hey All.

I've got a table of events, and each event is held by a "club" which is a related table.  That club table has the address of the club and the lat-long etc.

I need to search events by proximity: ie

<input  class="form-control" placeholder="postcode" type="text" name="fromAddress" value="<?php echo htmlencode(@$_REQUEST['fromAddress']); ?>" />

And display results ie:

// set default values (not required)
if (!array_key_exists('fromAddress', $_REQUEST)) { $_REQUEST['fromAddress'] = '4000'; } // this is the default address/postalcode if none entered

// get geocoding data
list($myLat, $myLng) = geocodeAddress( @$_REQUEST['fromAddress'] );
$kmOrMiles = 'km'; // can be 'miles' or 'km'
$geoOptions = geocoder_getOptions($myLat, $myLng, @$_REQUEST['maxDistance'], $kmOrMiles);


// get records
list($addressRecords, $addressMetaData) = getRecords(array(
'tableName' => 'events',
) + $geoOptions); // geoOptions WILL NOT override the above options

// error checking
$errorsAndAlerts = '';
if (@$_REQUEST['search']) {
if (!@$_REQUEST['fromAddress']) { $errorsAndAlerts .= "No address entered!<br/>\n"; }
elseif (!$myLat || !$myLng) { $errorsAndAlerts .= "We couldn't determine your location, please try again!<br/>\n"; }
}

However, I need to list the events table, using lat-long from the related events...

Any ideas?

Cheers,

Tim (toledoh.com.au)