Example: User types in "Ste" and that will offer suggestions Steve Jones AND Steve Hanson (so the first name that matches the letters, AND the last name. The code is there, just need to assign $a[] with Fname *space* Lname
Code: Select all
<?php
include('inc.php');
$result = mysql_query("SELECT * FROM loginphp") or die(mysql_error()); //query on the loginphp table where Fname and Lname are held
$row = mysql_fetch_array( $result ); //assigns $row
// Fill up array with names
$a[]="Steve"; //I want these to be set as $row['Fname'] $row['Lname'] so then they can do full name finds.
$a[]="Bob"; //Another example of the code... but again this needs to update from the DB.
//get the q parameter from URL
$q=$_GET["q"];
//lookup all hints from array if length of q>0
if (strlen($q) > 0)
{
$hint="";
for($i=0; $i<count($a); $i++)
{
if (strtolower($q)==strtolower(substr($a[$i],0,strlen($q))))
{
if ($hint=="")
{
$hint=$a[$i];
}
else
{
$hint=$hint." , ".$a[$i];
}
}
}
}
// Set output to "no suggestion" if no hint where found
// or to the correct values
if ($hint == "")
{
$response="no suggestion";
}
else
{
$response=$hint;
}
//output the response
echo $response;
?>