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 form to add property


  1. 1. Create a file /path/to/webroot/properties/add.php with the following content:

    <?php
    /**
    * File: /path/to/webroot/properties/add.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'];
    }
    // Get the list of localities
    $query = "SELECT id, name FROM localities";
    foreach ($dbh->query($query) as $row) {
    $viewVars['localities'][$row['id']] = $row['name'];
    }
    // Get the list of amenities
    $query = "SELECT id, name FROM amenities";
    foreach ($dbh->query($query) as $row) {
    $viewVars['amenities'][$row['id']] = $row['name'];
    }
    // If form is submitted then save the data
    // We aren't doing any validation but in a real
    // web application you should.
    if (!empty($_POST['description'])) {
    // Query to insert the property
    $query = "INSERT INTO
    properties
    SET
    type = :type,
    transaction_type = :transaction_type,
    description...