|  |  | 
          
            | PHP MSSQl ฟอร์มค้นหาข้อมูลแบบ list ไม่แสดงผลลัพธ์ 
 ตอนแรกผมโพสไปว่าดัดแปลงมาจากกระทู้ในเวบ  ในช่อง search มันเป็น text ซึ่งสามารถแสดงผลลัพธ์ได้ครับ
 
 แต่พอเปลี่ยนเป็นค้นหา List ผลปรากฏว่ามันค้นหา ไม่ออกเลยครับ  พี่ๆๆช่วยดูไห้หน่อย
 
 <html>
 <head>
 <title>................<<..>>.............</title>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-874"></head>
 <body>
 <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
 <table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td> </td>
 </tr>
 </table>
 <table width="467" border="1" align="center">
 <tr>
 <th width="129" align="left"><p>รหัสบัตรประชาชน</p></th>
 <th width="322" align="left"><input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>"></th>
 </tr>
 <tr>
 <th align="left">เพศ</th>
 <th align="left"><select name="txtKeyword2" id="txtKeyword2">
 <option>- Select -</option>
 <option value="<?=$_GET["ชาย"];?>">ชาย</option>
 <option value="<?=$_GET["หญิง"];?>">หญิง</option>
 </select></th>
 
 </tr>
 <tr>
 <th align="left">ชื่อ</th>
 <th align="left"><input name="txtKeyword3" type="text" id="txtKeyword3" value="<?=$_GET["txtKeyword3"];?>"></th>
 </tr>
 <tr>
 <th align="left">เขต / อำเภอ</th>
 <th align="left"><input name="txtKeyword4" type="text" id="txtKeyword4" value="<?=$_GET["txtKeyword4"];?>"></th>
 </tr>
 <tr>
 <th align="left">การศึกษา</th>
 <th align="left"><select name="txtKeyword5" id="txtKeyword5">
 <option>- Select -</option>
 <option value="<?=$_GET["ประถมศึกษา"];?>">ประถมศึกษา</option>
 <option value="<?=$_GET["มัธยมศึกษา"];?>">มัธยมศึกษา</option>
 <option value="<?=$_GET["อนุปริญญา"];?>">อนุปริญญา</option>
 <option value="<?=$_GET["ปริญญาตรี"];?>">ปริญญาตรี</option>
 <option value="<?=$_GET["ปริญญาโท"];?>">ปริญญาโท</option>
 <option value="<?=$_GET["ปริญญาเอก"];?>">ปริญญาเอก</option>
 </select></th>
 </tr>
 <tr>
 <th align="left">อาชีพ</th>
 <th align="left"><input name="txtKeyword6" type="text" id="txtKeyword6" value="<?=$_GET["txtKeyword6"];?>"></th>
 </tr>
 <tr>
 <th align="left">รายได้ต่อเดือน</th>
 <th align="left"><input name="txtKeyword7" type="text" id="txtKeyword7" value="<?=$_GET["txtKeyword7"];?>"></th>
 </tr>
 <tr>
 <th> </th>
 <th> </th>
 </tr>
 <tr>
 <th><input type="submit" value="Search"></th>
 <th> </th>
 </tr>
 </table>
 </form>
 <?
 include("../config.inc.php") ;
 // Search By Name or Email
 $strSQL = "SELECT  * FROM  Member WHERE (IDCard LIKE '%".$_GET["txtKeyword"]."%'
 and  Sex LIKE '%".$_GET["txtKeyword2"]."%'
 and  FName LIKE '%".$_GET["txtKeyword3"]."%'
 and  District LIKE '%".$_GET["txtKeyword4"]."%'
 and  Education LIKE '%".$_GET["txtKeyword5"]."%'
 and  Occuption LIKE '%".$_GET["txtKeyword6"]."%'
 and  Income LIKE '%".$_GET["txtKeyword7"]."%')  ";
 $objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
 $Num_Rows = mssql_num_rows($objQuery);
 
 $Per_Page = 10;   // Per Page
 
 $Page = $_GET["Page"];
 if(!$_GET["Page"])
 {
 $Page=1;
 }
 
 $Prev_Page = $Page-1;
 $Next_Page = $Page+1;
 
 $Page_Start = (($Per_Page*$Page)-$Per_Page);
 if($Num_Rows<=$Per_Page)
 {
 $Num_Pages =1;
 }
 else if(($Num_Rows % $Per_Page)==0)
 {
 $Num_Pages =($Num_Rows/$Per_Page) ;
 }
 else
 {
 $Num_Pages =($Num_Rows/$Per_Page)+1;
 $Num_Pages = (int)$Num_Pages;
 }
 $Page_End = $Per_Page * $Page;
 IF ($Page_End > $Num_Rows)
 {
 $Page_End = $Num_Rows;
 }
 
 ?>
 <table width="80%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr>
 <td><table width="1021" border="1" align="center">
 <tr>
 <th width="91"> <div align="center">บัตรประชาชน</div></th>
 <th width="203"> <div align="center">ชื่อ</div></th>
 <th width="131">เพศ</th>
 <th width="218">เขต / อำเภอ</th>
 <th width="182">การศึกษา</th>
 <th width="156"> <div align="center">รายได้ต่อเดือน</div></th>
 </tr>
 <?
 for($i=$Page_Start;$i<$Page_End;$i++)
 {
 ?>
 <tr>
 <td><div align="center">
 <?=mssql_result($objQuery,$i,"IDCard");?>
 </div></td>
 <td><?=mssql_result($objQuery,$i,"FName");?></td>
 <td><?=mssql_result($objQuery,$i,"Sex");
 ?></td>
 <td><?=mssql_result($objQuery,$i,"District");
 ?></td>
 <td><?=mssql_result($objQuery,$i,"Education");
 
 ?></td>
 <td><?=mssql_result($objQuery,$i,"Income");
 ?></td>
 </tr>
 <?
 }
 ?>
 </table>
 <br>
 Total
 <?= $Num_Rows;?>
 Record :
 <?=$Num_Pages;?>
 Page :
 <?
 if($Prev_Page)
 {
 echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_GET[txtKeyword]'><< Back</a> ";
 }
 
 for($i=1; $i<=$Num_Pages; $i++){
 if($i != $Page)
 {
 echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_GET[txtKeyword]'>$i</a> ]";
 }
 else
 {
 echo "<b> $i </b>";
 }
 }
 if($Page!=$Num_Pages)
 {
 echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_GET[txtKeyword]'>Next>></a> ";
 }
 
 mssql_close($objConnect);
 
 ?></td>
 </tr>
 </table>
 <br>
 </body>
 </html>
 
 
  
 
 
 Tag : PHP, Ms SQL Server 2005
 
 
 |  
            |  |  
            | 
              
                |  |  |  |  
                |  | 
                    
                      | Date :
                          2013-08-23 18:02:31 | By :
                          วันพีช | View :
                          893 | Reply :
                          1 |  |  |  
                |  |  |  |  |  
            |  |  
		            |  |