Book Image

Sphinx Search Beginner's Guide

By : Abbas Ali
Book Image

Sphinx Search Beginner's Guide

By: Abbas Ali

Overview of this book

Table of Contents (15 chapters)
Sphinx Search
Credits
About the Author
Acknowledgement
About the Reviewers
www.PacktPub.com
Preface

Time for action - creating the search form


  1. 1. Create a script /path/to/webroot/properties/geo_search.php with the following content:

    <?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;
    // Set the variables for view
    $viewVars['latitude'] = $latitude;
    $viewVars['longitude'] = $longitude;
    $viewVars['radius'] = $radius;
    render('geo_search');
    
  2. 2. Create the view for the geo search page at /path/to/webroot/properties/views/geo_search.thtml:

    <!-- File: /path/to/webroot/properties/views/geo_search.thtml -->
    <form action="geo_search.php" method="post">
    <fieldset>
    <legend>Geo Location Search</legend>
    <div class="input">
    <label>Latitude: </label>
    <input type="text" name="latitude...