<!-- To change this template, choose Tools | Templates and open the template in the editor. --> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ค้นหารายการข้อมูล</title> <link rel="stylesheet" type="text/css" href="/css/mystyle.css"> </head> <body> <!--ใส่ header เพื่อเปลี่ยน logo เพียงครั้งเดียวแล้วสั่งผลไปทุกหน้า--> <?php include "header.php"; include("class/phpconnectmysql.php"); //**** New class database ****// $strHost = "localhost"; $strDB = "db_project_pepsi"; $strUser = "root"; $strPassword = "ขขขขขขข"; $strTable = "tb_pepsi"; $clsMyDB = new MyDatabase($strHost,$strDB,$strUser,$strPassword); ?> <form name="frmSearch" method="get" action="<?php echo $_SERVER['SCRIPT_NAME'];?>"> <table align="center"> <tr> <?php //**** Call to class function select record ****// $clsMyDB->strTable = "tb_model"; //พิมพ์ เพื่อแจ้งค่าที่รับมาจากหน้าเวปก่อนหน้านี้ // echo "test".$_GET["asset_no"]; $clsMyDB->strCondition = " model<>'null'"; $clsMyDB->strColumn="model"; ?> <td align="left"> โมเดล : </td> <td align="left"> <select name="model" > <option value=" "></option> <?php foreach($clsMyDB->fncSelectRecord_array() as $rows) { ?> <option value="<?php echo $rows["model"]; ?>"><?php echo $rows["model"]; ?></option> <?php } ?> </select></td> <th>Asset No. <input name="txtKeyword" type="text" id="txtKeyword" size="6" maxlength="6" value="<?php echo $_GET["txtKeyword"];?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <?php if($_GET["txtKeyword"] != "" and $_GET["model"]) { //เริ่มติดต่อฐานข้อมูล mysql_connect($strHost,$strUser,$strPassword) or die ("ติดต่อฐานข้อมูลไม่ได้"); //เลือกฐานข้อมูล mysql_select_db($strDB) or die("เลือกฐานข้อมูลไม่ได้"); //คำสั่ง sql และสั่งให้ทำงาน $sql = "select * from ".$strTable." where model='".$_GET["model"]."' and asset_no like '%".$_GET["txtKeyword"]."%' order by serial_no asc"; // debug เพื่อแสดง sql syntax // echo $sql; $dbquery = mysql_db_query($strDB, $sql); //หาจำนวนเรคอร์ดข้อมูลในตาราง $num_rows = mysql_num_rows($dbquery); ?> <table align="center" border="1"> <tr> <th> <div align="center">Model </div></th> <th > <div align="center">Serial No. </div></th> <th > <div align="center">Asset No. </div></th> </tr> <?php //เริ่มวนรอบแสดงข้อมูล $i=0; while ($i<$num_rows) { $result = mysql_fetch_array($dbquery); ?> <td><div align="center"><?php echo $result["model"];?></div></td> <td><?php echo $result["serial_no"];?></td> <td><?php echo $result["asset_no"];?></td> <td><A HREF="Edit_tb_project_PEPSI.php?asset_no=<?php echo $result["asset_no"];?>" >แก้ไข</A><BR></td> <td><A HREF="Delete_tb_project_PEPSI.php?asset_no=<?php echo $result["asset_no"];?>" >ลบ</A><BR></td> </tr> <?php $i++; } //ปิดการติดต่อฐานข้อมูล mysql_close(); } ?> </table> </body> </html>
<?php foreach($clsMyDB->fncSelectRecord_array() as $rows) { $selection = ($row["model"]==$_GET["model"])?"selected":""; echo "<option value='".$rows["model"]."' $selection >".$rows["model"]."</option>"; } ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง