O'Reilly logo

Sphinx Search by Abbas Ali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action - adding code to perform geo distance search

  1. Modify /path/to/webroot/properties/geo_search.php and add the following (highlighted) code:
    <?php
    /**
    * File: /path/to/webroot/properties/geo_search.php
    */
    include('init.php');
    // Get the data from form (if submitted)
    $latitude = !empty($_POST['latitude']) ? $_POST['latitude'] : '';
    $longitude = !empty($_POST['longitude']) ? $_POST['longitude'] : '';
    $radius = !empty($_POST['radius']) ? $_POST['radius'] : 5;
    // If we have coordinates then perform the search if (!empty($latitude) && !empty($longitude)) { // Include the api class require_once('sphinxapi.php'); $client = new SphinxClient(); // Set search options $client->SetServer('localhost', 9312); $client->SetConnectTimeout(1); $client->SetArrayResult(true); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required