<html>
<head>
<title>gubig quick search</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
body,td,th {
font-family: Century Gothic, CordiaUPC, Calibri;
}
.style1 {font-size: 12px}
-->
</style>
</head>
<script language="JavaScript">
var HttPRequest = false;
function doCallAjax(Search) {
HttPRequest = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
HttPRequest = new XMLHttpRequest();
if (HttPRequest.overrideMimeType) {
HttPRequest.overrideMimeType('text/html');
}
} else if (window.ActiveXObject) { // IE
try {
HttPRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
HttPRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!HttPRequest) {
alert('Cannot create XMLHTTP instance');
return false;
}
var url = 'data.php';
var pmeters = 'mySearch='+Search;
HttPRequest.open('post',url,true);
HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
HttPRequest.setRequestHeader("Content-length", pmeters.length);
HttPRequest.setRequestHeader("Connection", "close");
HttPRequest.send(pmeters);
HttPRequest.onreadystatechange = function()
{
if(HttPRequest.readyState == 3) // Loading Request
{
document.getElementById("mySpan").innerHTML = "Now is Loading...";
}
if(HttPRequest.readyState == 4) // Return Request
{
document.getElementById("mySpan").innerHTML = HttPRequest.responseText;
}
}
}
</script>
<body Onload="JavaScript:doCallAjax('');">
<strong>say what you need ie. travel, shoping, buy.....and they will show up</strong> <strong>below</strong>
<form name="frmMain">
type your key words
<textarea name="txtSearch" cols="40" id="txtSearch"></textarea>
and
<input type="button" name="btnSearch" id="btnSearch" value="go > > >" OnClick="JavaScript:doCallAjax(document.getElementById('txtSearch').value);">
<br>
<br>
<span id="mySpan"></span>
</form>
</body>
</html>
แล้วดึงข้อมูลจากหน้านี้มาแสดง Code (PHP)
<?php
$strSearch = $_POST["mySearch"];
$objConnect = mysql_connect("localhost","root","pkknui") or die("Error Connect to Database");
$objDB = mysql_select_db("member");
$strSQL = "SELECT * FROM supplier WHERE name LIKE '%".$strSearch."%' or profile LIKE '%".$strSearch."%'ORDER BY name ASC ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?><style type="text/css">
<!--
body,td,th {
font-family: Century Gothic, CordiaUPC, Calibri;
}
.style1 {font-size: 16px}
-->
</style>
<table width="300" border="0">
<tr>
<th width="300"> <div align="center" class="style1">see who match your need</div></th>
</tr>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td height="20"><div align="left"><?=$objResult["name"];?>
| <?php $string = "www.gubig.com/manathai.php";
echo mb_convert_encoding($string , "HTML-ENTITIES" , "UTF-8");?>
</div></td>
</tr>
<?
}
?>
</table>
<?
mysql_close($objConnect);
?>
มันแสดงแบบนี้
say what you need ie. travel, shoping, buy.....and they will show up below
type your key words and
see who match your need
123456 | www.gubig.com/manathai.php
22222 | www.gubig.com/manathai.php
winsdenorth | www.gubig.com/manathai.php อยากให้ตรง url เป็น link ก็ยังดี
รบกวนด้วยนะครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript, Ajax, Report Others