<script language="JavaScript"> var HttPRequest = false; function doCallAjax(Page) { HttPRequest = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... HttPRequest = new XMLHttpRequest(); if (HttPRequest.overrideMimeType) { HttPRequest.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { HttPRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { HttPRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!HttPRequest) { alert('Cannot create XMLHTTP instance'); return false; } var url = '3.php'; var pmeters = 'myPage='+Page; HttPRequest.open('POST',url,true); HttPRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); HttPRequest.setRequestHeader("Content-length", pmeters.length); HttPRequest.setRequestHeader("Connection", "close"); HttPRequest.send(pmeters); HttPRequest.onreadystatechange = function() { if(HttPRequest.readyState == 3) // Loading Request { document.getElementById("mySpan").innerHTML = "Now is Loading..."; } if(HttPRequest.readyState == 4) // Return Request { document.getElementById("mySpan").innerHTML = HttPRequest.responseText; } } } </script> <body Onload="JavaScript:doCallAjax('1');"> <center><h1></h1> <div id="stylized" class="myform"> <form id="form" name="form" method="" onSubmit="return check()";> <p> เธเนเธเธซเธฒเธเนเธญเธกเธนเธฅเธเธฑเธเน€เธฃเธตเธขเธ เธ•เธฒเธกเธฃเธฒเธขเธเธธเธเธเธฅ</p> <select name="se" id="se"> <option value="">เธเนเธเธซเธฒเธ”เนเธงเธขเน</option> <option value="st_id">เธฃเธซเธฑเธช</option> <option value="st_fname">เธเธทเนเนเธญ</option> </select> <input type="text" name="txtsearch"> <button type="submit" name="button" id="button" onclick="doCallAjax(Page)">Search</button> <div class="spacer"></div> <? $level=$_GET['st_level']; //echo"GET:$level"; session_register("vel"); $_SESSION["vel"] = "$level"; //echo 'SESS'.$_SESSION['vel'].'<BR>'; ?> <script language="JavaScript"> function check(){ if(document.form.txtsearch.value==""){ alert("เธเธฃเธธเธ“เธฒเธเธฃเธญเธเธเนเธญเธกเธนเธฅเธ—เธตเนเธ•เนเธญเธเธเธฒเธฃเธเนเธเธซเธฒ") ; document.form.txtsearch.focus(); return false; } else if(document.form.se.value==""){ alert("เน€เธฅเธทเธญเธเธเธฃเธฐเน€เธ เธ—เธ—เธตเนเธ•เนเธญเธเธเธฒเธฃเธเนเธเธซเธฒ") ; document.form.se.focus(); return false; } else return true; } </script> </form> 3.php
<?php echo"TEXT:$txtsearch<BR>"; $strPage = $_POST["myPage"]; session_register("vel"); $id=$_SESSION['vel']; //echo'$id<BR>'; echo 'STUDENT LEVEL:'.$_SESSION['vel'].'<BR>'; include("connectDB.inc.php"); $objDB = mysql_select_db("dbst"); mysql_query("SET NAMES UTF8"); if($_GET["txtsearch"]!=""&&($_GET["se"]!="")) { if($_GET["se"]=="st_id"){ $strSQL = "SELECT * FROM tbst WHERE st_id LIKE'%$txtsearch%' AND st_level='$id'"; //$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); }else{ $strSQL = "SELECT * FROM tbst WHERE st_fname='%$txtsearch%' AND st_level='$id'"; //$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); //$Num_Rows = mysql_num_rows($objQuery); } }else{ $strSQL = "SELECT * FROM tbst WHERE st_level='$id'"; } $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); /* $strSQL = "SELECT * FROM tbst WHERE st_level='$id'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); */ $Per_Page = 20; // Per Page $Page = $strPage; if(!$strPage) { $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 st_id ASC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table class="three" cellspacing="0" align="center"> <!--<tr> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Nick Name </div></th> <th width="97"> <div align="center">BRDAY </div></th> <th width="59"> <div align="center">AGE </div></th> <th width="71"> <div align="center">Level </div></th> </tr> --> <tr> <th align="left">ID</th> <th align="left">Name</th> <th align="left">Nickname</th> <th align="left">Birthday</th> <th align="left">Age</th> <th align="left">Level</th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { $intRows++; ?> <tr> <td align="left"><?=$objResult["st_id"];?></td> <td align="left"><?=$objResult["st_mrs"]." ".$objResult["st_fname"]." ".$objResult["st_lname"];?></td> <td align="left"><?=$objResult["st_nickname"];?></td> <td align="left"><?=$objResult["st_brday"];?></td> <td align="left"><?=$objResult["st_age"];?></td> <td align="left"><?=$objResult["st_level"];?></td> </tr> <? } ?> <tr><th colspan='6' bgcolor="#FF9933" align="center"><span class="style1">Total Student <?=$intRows?> ID</span></th> </tr> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { echo " <a href=\"JavaScript:doCallAjax('$Prev_Page')\"><< Back</a> "; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "| <a href=\"JavaScript:doCallAjax('$i')\">$i</a> |"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { echo "<a href=\"JavaScript:doCallAjax('$Next_Page')\">Next >></a> "; } mysql_close($Connect); ?>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง