Proximity search of related table
2 posts by 2 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: April 14, 2017 (RSS)
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?
Tim (toledoh.com.au)
By ross - April 14, 2017
Hi Tim
I think we can get this going for you with some advanced SQL (ie: table joins).
That ends up being something we would look at for you through consulting.
You can either email me via consulting@interactivetools.com or we can leave this thread going and see if someone on the community has any examples to work from.
What do you think?
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com
Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/