<html> <head> <title>ThaiCreate.Com PHP & MySQL (mysqli)</title> </head> <body> <meta charset="utf-8"> <?php ini_set('display_errors', 1); error_reporting(~0); $strKeyword = null; if(isset($_POST["txtKeyword"])) { $strKeyword = $_POST["txtKeyword"]; } ?> <form name="frmSearch" method="post" action="<?php echo $_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?php echo $strKeyword;?>"> <input type="submit" value="Search"></th> </tr> </table> </form> <?php $serverName = "localhost"; $userName = "root"; $userPassword = ""; $dbName = "mydatabase2"; $conn = mysqli_connect($serverName,$userName,$userPassword,$dbName); mysqli_set_charset($conn, "utf8"); $sql = "SELECT * FROM type WHERE type LIKE '%".$strKeyword."%' "; $query = mysqli_query($conn,$sql); ?> <table width="600" border="1"> <tr> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Home Number </div></th> <th width="97"> <div align="center">type </div></th> <th width="59"> <div align="center">money </div></th> <th width="71"> <div align="center">datepay </div></th> </tr> <?php while($result=mysqli_fetch_array($query,MYSQLI_ASSOC)) { ?> <tr> <td><div align="center"><?php echo $result["name"];?></div></td> <td><?php echo $result["hnum"];?></td> <td><?php echo $result["type"];?></td> <td><div align="center"><?php echo $result["money"];?></div></td> <td align="right"><?php echo $result["datepay"];?></td> </tr> <?php } ?> </table> <?php mysqli_close($conn); ?> </body> </html>
SELECT * FROM type WHERE column1 LIKE '%".$strKeyword."%' OR column2 LIKE '%".$strKeyword."%' OR ...
"SELECT * FROM type WHERE " . $filter . " LIKE '%".$strKeyword."%' "
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง