Chapter 6. Property Search

In the previous chapter we saw a very simple application that performed a full-text search on the feed items. In this chapter we will create a more advanced application. So pull up your socks, and get ready to build a complex search application that will search through real estate property listings.

In this chapter we shall:

  • Create a form to add properties
  • Create a form to perform simple full-text search on properties
  • Create an advanced search form
  • Create a form to perform geo-location based searching

So let's get on with it...

The application

This application will search a database of real estate properties. We will create this database and populate it with some data. A property will have the following associated information (fields):

  • Property type
  • Description
  • Price
  • City
  • Address
  • Zip code
  • Number of bedrooms
  • Number of bathrooms
  • Property area
  • Year in which the property was built
  • Geo-coordinates of the property
  • Amenities

We will be creating different search forms; such as a simple, an advanced, and a geo location based search. These forms will have the following characteristics:

  • Simple: A city based filter and full-text search with different weights assigned to each field. We will have a drop-down from which the user can select the city, and a text box to enter search keywords.
  • Advanced: A purely filter based search. We will also use ranged filters in this form. A user will be able to specify the type of property, budget, minimum number of bedrooms, minimum area, and the age of the property as search criteria.
  • Geo location: In this form we will ask for coordinates of the location and search for all nearby properties.

Tools and software used while creating this application

We will be using the following software and tools to build this application:

  • PHP 5.3.2
  • Apache 2.2.14
  • MySQL 5.1.14
  • Sphinx 0.9.9
  • phpMyAdmin (to manage the database)
  • Ubuntu 10.04 LTS
  • Firefox 3.6

We will be building this application on the same lines as we did in the previous chapter. We will use the same HTML/CSS to build our views.

Database structure

Let's get started by creating the database structure. Firstly, we will need a table to hold the property's data; such as type, description, price, number of bedrooms, and so on. We will call this table properties.

Each property will be located in a city. It will make sense to normalize the city data so that the same city can be used for multiple properties. To do this, we will create a table cities and relate it to the properties table.

We will also need to associate amenities (parking, swimming pools, gardens, and so on) to properties. Again we will normalize amenities and keep it in its own table. An amenity can be associated with multiple properties and a property can have multiple amenities. To create such an association we will create a table amenities_properties.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset