|
 |
|
ช่วยดูโค้ตให้หน่อยครับ การค้นหาด้วย listbox ทำแล้วมันรันออกมาเลยทั้งที่ยังไม่ได้กดเลือกหรือพิมพ์ข้อมูลอะไรเลย |
|
 |
|
|
 |
 |
|
ขอบคุณครับ จะลองแก้ไขดู ถ้าไม่ได้รบกวนถามต่อนะครับ
|
 |
 |
 |
 |
Date :
2014-02-22 17:46:42 |
By :
000123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มัน Error ที่โค้ต ส่วนสีแดงครับ
Code (PHP)
<form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1" align="center">
<tr>
<th>ค้นหา
<select name="ddlSelect" id="ddlSelect">
<option>- Select -</option>
<option value="onorder" <?if($_POST["ddlSelect"]=="NO_ORDER"){echo"selected";}?>>เลขที่ตรวจวัด</option>
<option value="idcustomer" <?if($_POST["ddlSelect"]=="ID_CUST"){echo"selected";}?>>รหัสลูกค้า</option>
<option value="namecustomer" <?if($_POST["ddlSelect"]=="NAME_CUST"){echo"selected";}?>>ชื่อลูกค้า</option>
</select>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<p>
<?
if($_POST){
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("CEM");
// Search By Name or Email
$strSQL = "SELECT * FROM order_hd WHERE 1 ";
if($_POST["ddlSelect"] != "" and $_POST["txtKeyword"] != '')
{
$strSQL .= " AND (".$_POST["ddlSelect"]." LIKE '%".$_POST["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
} // if $_POST
?>
</p>
<p> </p>
<table width="916" border="1">
<tr>
<td width="109" bgcolor="#99FF66"><div align="center"><span class="style15">เลขที่ตรวจ</span></div></td>
<td width="102" bgcolor="#99FF66"><div align="center" class="style15">วันที่</div></td>
<td width="219" bgcolor="#99FF66"><span class="style15">ชื่อลูกค้า</span></td>
<td width="84" bgcolor="#99FF66"><span class="style15">รหัสบริการ</span></td>
<td width="238" bgcolor="#99FF66"><span class="style15">ชื่อบริการ</span></td>
<td width="124" bgcolor="#99FF66"><div align="center" class="style15">สถานะ</div></td>
</tr>
<?
if(mysql_num_rows($objQuery)>0){
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td bgcolor="#FFCCCC"><div align="center" class="style18"><?=$objResult["NO_ORDER"];?></div></td>
<td bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["DATE_ORDER"];?>
</span></td>
<td bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["ID_CUST"];?>
</span></td>
<td bgcolor="#FFCCCC"><div align="center" class="style18"><?=$objResult["ID_SER"];?></div></td>
<td align="right" bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["NAME_SER"];?>
</span></td>
<td align="right" bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["STUST"];?>
</span></td>
</tr>
<?
}
} // if num_rows
?>
</table>
<?
mysql_close($objConnect);
?>
|
 |
 |
 |
 |
Date :
2014-02-22 17:59:52 |
By :
000123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอโทษคับ ส่วนนี้คับ
if(mysql_num_rows($objQuery)>0)
กับส่วนปิดฐานข้อมูล
mysql_close($objConnect);
|
 |
 |
 |
 |
Date :
2014-02-22 18:07:57 |
By :
000123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองย้ายที่ดูครับ
Code (PHP)
<form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="1" align="center">
<tr>
<th>ค้นหา
<select name="ddlSelect" id="ddlSelect">
<option>- Select -</option>
<option value="onorder" <?if($_POST["ddlSelect"]=="NO_ORDER"){echo"selected";}?>>เลขที่ตรวจวัด</option>
<option value="idcustomer" <?if($_POST["ddlSelect"]=="ID_CUST"){echo"selected";}?>>รหัสลูกค้า</option>
<option value="namecustomer" <?if($_POST["ddlSelect"]=="NAME_CUST"){echo"selected";}?>>ชื่อลูกค้า</option>
</select>
Keyword
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_POST["txtKeyword"];?>">
<input type="submit" value="Search"></th>
</tr>
</table>
</form>
<p>
<?
if($_POST){
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("CEM");
// Search By Name or Email
$strSQL = "SELECT * FROM order_hd WHERE 1 ";
if($_POST["ddlSelect"] != "" and $_POST["txtKeyword"] != '')
{
$strSQL .= " AND (".$_POST["ddlSelect"]." LIKE '%".$_POST["txtKeyword"]."%' ) ";
}
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
</p>
<p> </p>
<table width="916" border="1">
<tr>
<td width="109" bgcolor="#99FF66"><div align="center"><span class="style15">เลขที่ตรวจ</span></div></td>
<td width="102" bgcolor="#99FF66"><div align="center" class="style15">วันที่</div></td>
<td width="219" bgcolor="#99FF66"><span class="style15">ชื่อลูกค้า</span></td>
<td width="84" bgcolor="#99FF66"><span class="style15">รหัสบริการ</span></td>
<td width="238" bgcolor="#99FF66"><span class="style15">ชื่อบริการ</span></td>
<td width="124" bgcolor="#99FF66"><div align="center" class="style15">สถานะ</div></td>
</tr>
<?
if((mysql_num_rows($objQuery)>0)){
while($objResult = mysql_fetch_array($objQuery))
{
?>
<tr>
<td bgcolor="#FFCCCC"><div align="center" class="style18"><?=$objResult["NO_ORDER"];?></div></td>
<td bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["DATE_ORDER"];?>
</span></td>
<td bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["ID_CUST"];?>
</span></td>
<td bgcolor="#FFCCCC"><div align="center" class="style18"><?=$objResult["ID_SER"];?></div></td>
<td align="right" bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["NAME_SER"];?>
</span></td>
<td align="right" bgcolor="#FFCCCC"><span class="style18">
<?=$objResult["STUST"];?>
</span></td>
</tr>
<?
}
} // if num_rows
?>
</table>
<?
mysql_close($objConnect);
} // if $_POST
?>
|
 |
 |
 |
 |
Date :
2014-02-22 18:18:22 |
By :
ผู้มาเยือน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆๆครับ ได้แล้ว ถามที่โค้ตเลยครับ
|
 |
 |
 |
 |
Date :
2014-02-22 21:02:29 |
By :
000123 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|