<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-874" /> <title>Untitled Document</title> </head> <body> <form action="<? $_SERVER['SCRIPT_NAME'];?>" method="get" name="frmSearch"> <table width="300" border="0"> <tr> <th>Keyword <input type="text" name="txtKeyword" id="txtKeyword" value="<?=$_GET["txtKeyword"];?> "/></th> <th><input type="submit" value="Search" /></th> </tr> </table> </form> <? if($_GET["txtKeyword"]!="") { $conn = mysql_connect("localhost","root","root") or die (mysql_error()); $objconn=mysql_select_db("connectdb"); //Search by name or Email $sql="SELECT * FROM customer WHERE (Name LIKE '%".$_GET["txtKeyword"]."%' or Email LIKE '%".$_GET["txtKeyword"]."%')"; echo $sql."<br>" ; $query = mysql_query($sql) or die (mysql_error()); $num_rows = mysql_num_rows($query); $per_page = 2; // Per Page $page = $_GET["Page"]; if(!$_GET["Page"]) { $page = 1; }//if $prev_page = $Page-1; $next_page = $Page+1; $page_start = (($per_page*page)-$per_page); if ($num_rows<=$per_page) { $num_pages = 1; }//if else if (($num_rows % $per_page)==0) { $num_pages = ($num_rows / $per_page); }//else if else { $num_pages = ($num_rows / $per_page)+1; $num_pages = (int)$num_pages; }//else $sql.="ORDER BY CustomerID ASC LIMIT $page_start,$per_page"; $query=mysql_query($sql) or die (mysql_error()); echo "sql : ".$sql; ?> <table width="800" border="1" cellspacing="0" cellpadding="0" bordercolor="#333333"> <tr bgcolor="#FFFFFF"> <th><div align="center">CustomerID</div></th> <th><div align="center">Name</div></th> <th><div align="center">E-mail</div></th> <th><div align="center">Country Code</div></th> <th><div align="center">Budget</div></th> <th><div align="center">Used</div></th> </tr> <? while ($rec=mysql_fetch_assoc($query)) { ?> <tr bgcolor="#FFFFFF"> <td><div align="center"><?=$rec["CustomerID"];?></div></td> <td width="30%"><?=$rec["Name"];?></td> <td width="30%"><?=$rec["Email"];?></td> <td width="20%"><div align="center"><?=$rec["CountryCode"]?></div></td> <td width="20%"><div align="right"><?=$rec["Budget"];?></div></td> <td width="20%"><div align="right"><?=$rec["Used"];?></div></td> </tr> <? }//while ?> </table> <br> Total : <?=$num_rows;?> Recode : <?=$num_pages?> Page : <? if ($per_page) { echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$prev_page&txtKeyword=$_GET[txtKeyword]'><< Back</a>"; }//if 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 }//for if ($page !=$num_pages) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$next_page&txtKeyword=$_GET[txtKeyword]'>Next>></a> "; }//if mysql_close($conn); }//if ?> </body> </html>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง