Character by Character search in input box.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pizzipie
Forum Commoner
Posts: 87
Joined: Wed Feb 10, 2010 10:59 pm
Location: Hayden. ID

Character by Character search in input box.

Post by pizzipie »

I am trying to duplicate the input actions of the Thunderbird Address search box. Say you want to find the name 'Williamson'. When you type the 'W' into the box you will get a lookup table of all names beginning with 'W'. When you type the 'i' you will get a lookup table showing all names beginning with 'Wi'. When you type the 'l' you will get a lookup table showing all names beginning with 'Wil'. This goes on until you click on the name you want as shown in the lookup table.

Can anyone direct me to some code or whatever to explain how to do this.

I have limited experience programming (I don't know the advanced stuff ie: templates, OOP etc.) so I don't know if this is beyond me or not. I use Ubuntu 9.04 LAMP for my programming.

Thanks in advance,

Rick P.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Character by Character search in input box.

Post by pbs »

I think you need functionality like textbox autofill, you can search "autofill" in google.
pbs
Forum Contributor
Posts: 230
Joined: Fri Nov 07, 2008 5:31 am
Location: Nashik, India
Contact:

Re: Character by Character search in input box.

Post by pbs »

pizzipie
Forum Commoner
Posts: 87
Joined: Wed Feb 10, 2010 10:59 pm
Location: Hayden. ID

Re: Character by Character search in input box.

Post by pizzipie »

:P SOLVED Thanks for the information. I implemented this by using a text form and doing a query using LIKE "%text%" on the results of the
submit info. If anyone is interested here is partial code:

NOTE: This code was adapted from examples in Chapter 6. of PHP and MySQl O'Reilly: Hugh E. Williams & David Lane 2nd Edition

<form method="post" action="<?php echo $PHP_SELF; ?>">
<p>Type partial Name to search for:<br>
or nothing for all names<br>
<input type="text" name="partname" />
</p>
<p><input type="submit" value="Partial Name"></p>
</form>
<?php
$partname=$_POST["partname"];
?>

<form action="AddressDisplayP.php" method="GET">

<?php

// Include File - /usr/share/php/include/
require "db-address.inc";
require "functions.inc";

// Connect to the server
if (!($connection = @ mysql_connect($hostName, $username, $password)))
showerror();

if (!mysql_select_db($databaseName, $connection))
showerror();


/* Produce the select list
Parameters:
1: Database connection .................... $connection
2. Table that contains values ............. people
3. Attribute/field that contains values ... Display_Name
4. <SELECT> element name .................. Display_Name
5. Optional <OPTION SELECTED> ............. All
6. User Selected Partial name to search on .... $partname
*/

selectDistinct($connection, "people", "Display_Name", "Display_Name", "All", $partname);

/*
// Query to find distinct values of $fieldName in $tableName This code is inside function selectDistinct(....) as above.
$distinctQuery = "SELECT DISTINCT {$fieldName} FROM
{$tableName} WHERE {$selectedName} LIKE '%$partname%'";
*/

?>
<br>

<input type="submit" value="Name" />


</form>
Post Reply