<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="955" border="1"> <tr> <th width="945">Keyword <input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>" size="38" > <input type="submit" value="Search"></th> </tr> </table> </form> <? if($_GET["txtKeyword"] != "") { $objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database"); $objDB = mysql_select_db("test"); $strSQL = "SELECT * FROM new WHERE (id LIKE '%".$_GET["txtKeyword"]."%' or detail LIKE '%".$_GET["txtKeyword"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_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; } $strSQL .=" order by id ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="954" border="1"> <tr> <th width="107" height="27"> <div align="center">]ลำดับที่</div></th> <th width="168"> <div align="center">ข่าว </div></th> <th width="490"> <div align="center">บทความที่เกี่ยวข้อง </div></th> <th width="161"> <div align="center">หมายเหตุ</div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td height="25"><div align="center"> <?=$objResult["id"];?> </div></td> <td><?=$objResult["new"];?></td> <td><?=$objResult["detail"];?></td> <td><div align="center"> <?=$objResult[""];?> </div></td> </tr> <? } ?> </table><br> <br> <? $txtKeyword = $_GET[txtKeyword]; if(isset($txtKeyword) ) { echo "<font size='-3' color='#FF0000'>ผลลัพธ์ของคำว่า [ $txtKeyword ] </font><br />";} ?> ค้นพบ <?= $Num_Rows;?> คำ : แสดงใน <?=$Num_Pages;?>หน้า : <? 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> "; } mysql_close($objConnect); } ?>
while($row=mysql_fetch_array($objQuery)){ // ตรงนี้ก็สามารถ แสดง แต่ละฟิลด์ที่ต้องการแสดงได้เลยครับ เช่น echo '<a href="#">'.$row['news'].' '.$row['detail '].'</a><br>'; }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง