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/feeds/search.php with the following content:

    <?php
    /**
    * File: /path/to/webroot/feeds/search.php
    */
    include('init.php');
    // Get all the categories and their ids
    // This will be used to build the categories filter drop down
    $query = "SELECT id, name FROM categories ORDER BY name";
    foreach ($dbh->query($query) as $row) {
    $viewVars['cat_list'][$row['id']] = $row['name'];
    }
    // Render the page
    render('search');
    
  2. 2. Create the view for the search page at /path/to/webroot/feeds/views/search.thtml:

    <!-- File: /path/to/webroot/feeds/views/search.thtml -->
    <form action="search.php" method="post">
    <fieldset>
    <legend>Search Feeds</legend>
    <div class="input">
    <label>Search for:</label>
    <input type="text" name="q" value="" />
    </div>
    <div class="input">
    <label>Author:</label>
    <input type="text" name="author" value="" />
    </div>
    &lt...