<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<select name="txtKeyword2" class="style5" >
<option value="">--- เลือก ---</option>
<?
$strSQL = "SELECT * FROM province WHERE Enable='T' order by PROVINCE_NAME ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mssql_fetch_array($objQuery))
{
?>
<option value="<?=$objResult["PROVINCE_ID"];?>">
<?=$objResult["PROVINCE_NAME"];?>
</option>
<?}?>
</select>
<input name="txtKeyword" type="text" class="style5" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>" size="70">
<input type="submit" class="button2" value="Search">
</form>
<?
if($_GET["txtKeyword"]!= "")
{
$keyword = explode(" ", $_GET["txtKeyword"]);
for($h= 0; $h < count ($keyword); $h++){
}
$strSQL = "SELECT TOP (1) detail.ThaiName, detail.EngName, detail.word, detail.type, detail.orther, detail.Address, detail.province, detail.amphur, detail.district, detail.zip,
detail.mail, detail.web, detail.hotline, detail.busi, detail.bg, detail.etc, detail.detail, detail.price, detail.branch, detail.commonday1,detail.commonday2, detail.holiday1,detail.holiday2, detail.element,
detail.note, detail.town1, detail.town2, detail.town3, detail.town4, detail.rate, detail.Created, detail.CreatedBy, detail.CreatedTime, detail.Updated,
detail.UpdatedBy, detail.UpdatedTime, detail.IsSecret, detail.IsActive, detail.Enable, detail.Deleted, detail.DeletedBy, detail.DeletedTime, tel.tel, fax.fax, contact.con_name, contact.c_name, contact.c_lastname, contact.c_add,
contact.c_province, contact.c_amphur, contact.c_district, contact.c_zip, contact_tel.c_tel
FROM detail INNER JOIN
tel ON detail.id_detail = tel.id_detail INNER JOIN
fax ON detail.id_detail = fax.id_detail INNER JOIN
contact ON detail.id_detail = contact.id_detail INNER JOIN
contact_tel ON contact.id_con = contact_tel.id_con
WHERE detail.Enable='T' AND detail.IsActive='T' AND
(tel.tel LIKE '%".$keyword[0]."%' or fax.fax LIKE '%".$keyword[0]."%' or contact_tel.c_tel LIKE '%".$keyword[0]."%' or detail.hotline LIKE '%".$keyword[0]."%')
and
(tel.tel LIKE '%".$keyword[1]."%' or fax.fax LIKE '%".$keyword[1]."%' or contact_tel.c_tel LIKE '%".$keyword[1]."%' or detail.hotline LIKE '%".$keyword[1]."%')
and
(tel.tel LIKE '%".$keyword[2]."%' or fax.fax LIKE '%".$keyword[2]."%' or contact_tel.c_tel LIKE '%".$keyword[2]."%' or detail.hotline LIKE '%".$keyword[2]."%')
and
(tel.tel LIKE '%".$keyword[3]."%' or fax.fax LIKE '%".$keyword[3]."%' or contact_tel.c_tel LIKE '%".$keyword[3]."%' or detail.hotline LIKE '%".$keyword[3]."%')
and
(tel.tel LIKE '%".$keyword[4]."%' or fax.fax LIKE '%".$keyword[4]."%' or contact_tel.c_tel LIKE '%".$keyword[4]."%' or detail.hotline LIKE '%".$keyword[4]."%')
and
(tel.tel LIKE '%".$keyword[5]."%' or fax.fax LIKE '%".$keyword[5]."%' or contact_tel.c_tel LIKE '%".$keyword[5]."%' or detail.hotline LIKE '%".$keyword[5]."%')
and
(tel.tel LIKE '%".$keyword[6]."%' or fax.fax LIKE '%".$keyword[6]."%' or contact_tel.c_tel LIKE '%".$keyword[6]."%' or detail.hotline LIKE '%".$keyword[6]."%')
and
(tel.tel LIKE '%".$keyword[7]."%' or fax.fax LIKE '%".$keyword[7]."%' or contact_tel.c_tel LIKE '%".$keyword[7]."%' or detail.hotline LIKE '%".$keyword[7]."%')
and
(tel.tel LIKE '%".$keyword[8]."%' or fax.fax LIKE '%".$keyword[8]."%' or contact_tel.c_tel LIKE '%".$keyword[8]."%' or detail.hotline LIKE '%".$keyword[8]."%')
and
(tel.tel LIKE '%".$keyword[9]."%' or fax.fax LIKE '%".$keyword[9]."%' or contact_tel.c_tel LIKE '%".$keyword[9]."%' or detail.hotline LIKE '%".$keyword[9]."%')";
if($_GET["txtKeyword2"]!= "")
{
$strSQL .= " and (detail.province LIKE '%".$_GET["txtKeyword2"]."%') ";
}
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<table width="600" border="1">
<tr>
<th width="91"> <div align="center">ID</div></th>
<th width="98"> <div align="center">Tel</div></th>
</tr>
<?
while($objResult = mssql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center"><?=$objResult["id_tel"];?></div></td>
<td><?=$objResult["tel"];?></td>
<td><?=$objResult["id_detail"];?></td>
</tr>
<?
}
?>
</table>
<?
mssql_close($objConnect);
}
?>