if(!$db) {
// Show error if we cannot connect.
echo 'ERROR: Could not connect to the database.';
} else {
// Is there a posted query string?
if(isset($_POST['queryString'])) {
$queryString = $db->real_escape_string($_POST['queryString']);
// Is the string length greater than 0?
if(strlen($queryString) >0) {
$query = $db->query("SELECT * FROM i_student WHERE stid LIKE '%" . $queryString . "%' ORDER BY stid LIMIT 8");
mysql_query("SET NAMES TIS620");
mysql_query("SET character_set_results=tis-620");
mysql_query("SET character_set_client=tis-620");
mysql_query("SET character_set_connection=tis-620");
if($query) {
// While there are results loop through them - fetching an Object.
// Store the category id
$stid = 0;
while ($result = $query ->fetch_object()) {
if($result->stid != $stid) { // check if the category changed
echo '<span class="category">'.$result->firstname.'</span>';
$stid = $result->stid;
}
//echo '<a href="'.$result->url.'">';
//echo '<img src="search_images/'.$result->img.'" alt="" />';
echo '<span>'.$description.'</span></a>';
}
echo '<span class="seperator">'.$firstname.'</span><br class="break" />';
} else {
echo 'ERROR: There was a problem with the query.';
}
} else {
// Dont do anything.
} // There is a queryString.
} else {
echo 'There should be no direct access to this script!';
}
}
?>
</p>
ส่วนอันนี้เป็น JS Code
[code]/*
* Author: Marco Kuiper (http://www.marcofolio.net/)
*/
google.load("jquery", "1.3.1");
google.setOnLoadCallback(function()
{
// Safely inject CSS3 and give the search results a shadow
var cssObj = { 'box-shadow' : '#888 5px 10px 10px', // Added when CSS3 is standard