 |
|
โค้ดประมาณนี้น่ะค่ะ
Code (PHP)
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="0">
<tr>
<th>ค้นหาข้อมูลสมุนไพร
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>">
<input type="submit" value="ค้นหา"></th>
</tr>
</table>
</form>
<?
if($_GET["txtKeyword"] != "")
{
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("herb");
// Search By Name or Email
$strSQL = "SELECT * FROM data_herb WHERE (Herb_Name LIKE '%".$_GET["txtKeyword"]."%' or Herb_Properties
LIKE '%".$_GET["txtKeyword"]."%' or Herb_NameSci LIKE '%".$_GET["txtKeyword"]."%'
or Herb_NameFamily LIKE '%".$_GET["txtKeyword"]."%'
or Herb_Botany LIKE '%".$_GET["txtKeyword"]."%')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<?
function hiligth($keySearch,$myStrong)
{
$varlue=str_replace($keySearch,"<font color=red><b>$keySearch<b></font>",$myStrong);
return $varlue;
}
while($objResult = mysql_fetch_array($objQuery))
{
?>
<div><strong>ชื่อสมุนไพร : </strong><?=hiligth($_GET["txtKeyword"],$objResult["Herb_Name"]);?> </div>
<div><strong>ชื่อวิทยาศาสตร์ : </strong><?=hiligth($_GET["txtKeyword"],$objResult["Herb_NameSci"]);?> </div>
<div><strong>ชื่อวงศ์ : </strong><?=hiligth($_GET["txtKeyword"],$objResult["Herb_NameFamily"]);?> </div>
<div><strong>ลักษณะทางฟฤกษศาสตร์ : </strong><?=hiligth($_GET["txtKeyword"],$objResult["Herb_Botany"]);?> </div>
<div><strong>สรรพคุณ : </strong><?=hiligth($_GET["txtKeyword"],$objResult["Herb_Properties"]);?> </div><BR><BR>
<?
}
?>
<?
mysql_close($objConnect);
}
?>
Tag : PHP, Ms SQL Server 2005, CakePHP
|
|
 |
 |
 |
 |
Date :
2010-11-03 15:48:13 |
By :
loverstrory |
View :
849 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |