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 Advanced search form


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

    <?php
    /**
    * File: /path/to/webroot/properties/search.php
    */
    include('init.php');
    // Get the list of cities
    $query = "SELECT id, name FROM cities";
    foreach ($dbh->query($query) as $row) {
    $viewVars['cities'][$row['id']] = $row['name'];
    }
    // Render the view
    render('search');
    
  2. 2. Create the view for the search page at /path/to/webroot/properties/views/search.thtml:

    <form action="advanced_search.php" method="post">
    <fieldset>
    <legend>Advanced search</legend>
    <div class="input">
    <label>City: </label>
    <select name="city_id">
    <?php foreach ($viewVars['cities'] as $id => $name):?>
    <option value="<?php echo $id; ?>">
    <?php echo $name; ?></option>
    <?php endforeach; ?>
    </select>
    </div>
    <div class="input">
    <label>Type: </label>
    <input type...