/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'),
/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> <div class="input"> feed search applicationfeed search applicationsearch form, creating<label>Category:</label> <select multiple="true" size="10" name="categories[]"> <?php foreach ($viewVars['cat_list'] as $id => $name): ?> <option value="<?php echo $id; ?>"> <?php echo $name; ?></option> <?php endforeach; ?> </select> </div> <div class="input"> <label> </label> <input type="submit" value="Search" name="search" /> </div> </fieldset> </form>
search.php
in a browser.We created a basic form to specify the search phrase, author name, and select multiple categories. We built the categories select box using the category labels we have in our database table.
Search will be performed against different fields as given next: