11.07.2015 Views

AJAX and PHP

AJAX and PHP

AJAX and PHP

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>AJAX</strong> Suggest <strong>and</strong> AutocompleteTime for Action—<strong>AJAX</strong> Suggest <strong>and</strong> Autocomplete1. As always, we start by creating the necessary database structures. Create a new tablenamed suggest in the ajax database that contains a single field (name), which is alsothe primary key:CREATE TABLE suggest(name VARCHAR(100) NOT NULL DEFAULT '',PRIMARY KEY (name));2. The suggest table will be populated with the complete list of <strong>PHP</strong> functions that wetook from http://www.php.net/quickref.php; because the table contains over4,000 records, we are listing only the first ten here. Please use the script from thecode download for the complete list:INSERT INTO suggest (name) VALUES('abs'),('acos'),('acosh'),('addcslashes'),('addslashes'),('aggregate'),('aggregate_info'),('aggregate_methods'),('aggregate_methods_by_list'),('aggregate_methods_by_regexp');3. Create a new folder named suggest, under the ajax folder.4. We will start by creating the code for the server side. In the suggest folder, create afile named config.php, <strong>and</strong> add the database configuration code to it (change thesevalues to match your configuration):5. Then add the st<strong>and</strong>ard error-h<strong>and</strong>ling file error_h<strong>and</strong>ler.php:168

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!