Login   Register  
PHP Classes

File: test_mdb2_auto_complete.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Manuel Lemos  >  Forms generation and validation  >  test_mdb2_auto_complete.php  >  Download  
File: test_mdb2_auto_complete.php
Role: Example script
Content type: text/plain
Description: Example to demonstrate how to auto-complete a text input with texts from a database using PEAR::MDB2 API
Class: Forms generation and validation
HTML forms generation and validation.
Author: By
Last change: Reformatted the code.
Used the function ConnectFormToInput to give the focus to an input
automatically when the page is loaded.
Date: 1 year ago
Size: 3,549 bytes


Class file image Download
 * test_mdb2_auto_complete.php
 * @(#) $Header: /opt2/ena/metal/forms/test_mdb2_auto_complete.php,v 1.2 2006/12/20 06:21:17 mlemos Exp $

require 'MDB2.php';

$database =& MDB2::connect($dsn);
    if (
PEAR::isError($database)) {

$form=new form_class;
'title'=>'Type just the first letters of a location.',
'title'=>'Click to show all locations.'
"CompleteValuesQuery"=>"SELECT name FROM locations WHERE name {BEGINSWITH} ORDER BY name",
'SubmitFeedback'=>' <img src="indicator.gif" width="16" height="16" alt="Looking up for locations" title="Looking up for locations" /> ',
'CompleteFeedback'=>' <img src="indicator.gif" width="16" height="16" style="visibility: hidden;" /> ',

     * This code is necessary to handle the requests for fetching
     * auto-complete values.

$form->ConnectFormToInput('location''ONLOAD''Focus', array());


?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Test for Manuel Lemos' PHP form class using the auto-complete plug-in input and PEAR::MDB2 to perform database queries</title>
<style type="text/css"><!--
BODY { color: black ; font-family: arial, helvetica, sans-serif ; background-color: #cccccc }
.groovymenu { background-color: #cccccc; padding: 4px; border-style: solid ; border-top-color: #f9f9f9 ; border-left-color: #f9f9f9 ; border-bottom-color: #868686 ; border-right-color: #868686 ; border-width: 1px; opacity: 0.9; filter: alpha(opacity=90); }
.groovyitem { padding: 1px; }
.groovyselecteditem { padding: 1px; color: #ffffff; background-color: #000080; }
// --></style>
<body onload="<?php echo $onload?>" bgcolor="#cccccc">
<center><h1>Test for Manuel Lemos' PHP form class using the auto-complete plug-in input and PEAR::MDB2 to perform database queries</h1></center>
<hr />
$title='Auto-complete plug-in test';


<hr />