<script language="JavaScript"> function ClickCheckAll(vol) { var i=1; for(i=1;i<=document.frmMain.hdnCount.value;i++) { if(vol.checked == true) { eval("document.frmMain.chkDeluser"+i+".checked=true"); } else { eval("document.frmMain.chkDeluser"+i+".checked=false"); } } } function submitFrmMain() { if(confirm('คุณต้องการลบข้อมูลนี้ใช่หรือไม่')==true) { document.frmMain.submit(); } } </script>
<tr> <td width="2%" ><div align="center"><b><input name="CheckAll" type="checkbox" id="CheckAll" value="Y" onClick="ClickCheckAll(this);"></b></div></td> <td width="3%"><div align="center"><span class="small"><b>ลำดับ</b></span></div></td> <td width="10%"><span class="small"><b>ชื่อเข้าสุ่ระบบ</b></span></td> <td width="20%" align="center" width="9%"><b>ชื่อผู้ใช้ระบบ</b></td> <td width="50%" align="center" width="9%"><b>ที่อยู่</b></td> <td width="20%" align="center" width="15%"><b>สถานะ</b></td> <td width="5%" align="center" width="15%"><b>แก้ไข</b></td> </tr> <?php $value = mysql_real_escape_string($_REQUEST['txtKeyword']); if(isset($_REQUEST['rdoserach']) == "all"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND (user.user_name LIKE '%$value%' OR admin.admin_name LIKE '%$value%')"; }elseif(isset($_REQUEST['rdoserach']) == "admin_name"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND admin.admin_name LIKE '%$value%'"; }elseif(isset($_REQUEST['rdoserach']) == "user_name"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND user.user_name LIKE '%$value%'"; }else{ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin'"; } //echo $Sql; $Query=mysql_query($Sql); $Num_Rows = mysql_num_rows($Query); $Per_Page = 20; // 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; } $Sql.=" order by user.user_id DESC LIMIT $Page_Start , $Per_Page"; $Query = mysql_query($Sql); $i = 1; if($Page > 1){ $i = ($Per_Page * ($Page-1)) + 1; $j = $i; } while ($Result = mysql_fetch_array($Query)) { $user_id = $Result['user_id']; $admin_id = $Result['admin_id']; $user_name = $Result['user_name']; $user_last = $Result['user_last']; $user_add = $Result['user_add']; $admin_name = $Result['admin_name']; $admin_password = $Result['admin_password']; $status = $Result['status']; print "<tr>"; print "<td class=\"tbl1\"><div align=\"center\"><input type=\"checkbox\" name=\"chkDeluser[]\" id=\"chkDeluser$i\" value=\"$user_id\"><input type=\"hidden\" name=\"chkDeladmin[]\" id=\"chkDeladmin$i\" value=\"$admin_id\"></div></td>"; print "<td ><div align=\"center\">$i</div></td>"; print "<td > $admin_name</td>"; print "<td > $user_name $user_last</td>"; print "<td > $user_add</td>"; print "<td >"; if($status == "Admin"){ echo "<font color=\"red\">ผู้ดูแลระบบ</font>"; }else{ echo "<font color=\"red\">สมาชิก</font>"; } print "</td>"; print "<td align=\"center\"><a id=\"variousedit\" href=\"formeditmember.php?user_id=$user_id&admin_id=$admin_id\"><img src=\"images/edit.png\" width=\"16\" height=\"16\" border=\"0\"></a></td>"; print "</tr>"; $i++; } ?> <tr> <td colspan="7" align="left"> <input type="hidden" name="hdnCount" value="<?php echo $i;?>"><div class="pagination">ทั้งหมด: <b><?php echo $Num_Rows;?></b> แสดงหน้า: <ul> <?php if($Prev_Page){ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"prevnext\">Previous</a></li>"; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page){ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]'>$i</a></li>"; }else{ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"currentpage\">$i</a></li>"; } } if($Page!=$Num_Pages){ echo "<li><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"prevnext\">Next</a></li>"; } ?> </ul> </div>
<script language="JavaScript"> function ClickCheckAll(vol) { //ส่วนที่เพิ่มเข้าไป var cpage = document.frmMain.pageCount.value; if(cpage > 1){ var chdn = document.frmMain.hdnCount.value; var cper = document.frmMain.perCount.value; var ncount = (cper * (cpage-1)) +1; for(var i=ncount;i<=document.frmMain.hdnCount.value;i++) { if(vol.checked == true) { eval("document.frmMain.chkDeluser"+i+".checked=true"); } else { eval("document.frmMain.chkDeluser"+i+".checked=false"); } } }else{ // ถึงตรงนี้ var i=1; for(i=1;i<=document.frmMain.hdnCount.value;i++) { if(vol.checked == true) { eval("document.frmMain.chkDeluser"+i+".checked=true"); } else { eval("document.frmMain.chkDeluser"+i+".checked=false"); } } }//และก็ปิดตรงนี้ } </script>
<tr> <td width="2%" ><div align="center"><b><input name="CheckAll" type="checkbox" id="CheckAll" value="Y" onClick="ClickCheckAll(this);"></b></div></td> <td width="3%"><div align="center"><span class="small"><b>ลำดับ</b></span></div></td> <td width="10%"><span class="small"><b>ชื่อเข้าสุ่ระบบ</b></span></td> <td width="20%" align="center" width="9%"><b>ชื่อผู้ใช้ระบบ</b></td> <td width="50%" align="center" width="9%"><b>ที่อยู่</b></td> <td width="20%" align="center" width="15%"><b>สถานะ</b></td> <td width="5%" align="center" width="15%"><b>แก้ไข</b></td> </tr> <?php $value = mysql_real_escape_string($_REQUEST['txtKeyword']); if(isset($_REQUEST['rdoserach']) == "all"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND (user.user_name LIKE '%$value%' OR admin.admin_name LIKE '%$value%')"; }elseif(isset($_REQUEST['rdoserach']) == "admin_name"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND admin.admin_name LIKE '%$value%'"; }elseif(isset($_REQUEST['rdoserach']) == "user_name"){ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin' AND user.user_name LIKE '%$value%'"; }else{ $Sql="SELECT * FROM user LEFT JOIN admin ON user.admin_id = admin.admin_id "; $Sql.=" WHERE admin.admin_name <> 'admin'"; } //echo $Sql; $Query=mysql_query($Sql); $Num_Rows = mysql_num_rows($Query); $Per_Page = 20; // 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; } $Sql.=" order by user.user_id DESC LIMIT $Page_Start , $Per_Page"; $Query = mysql_query($Sql); $i = 1; if($Page > 1){ $i = ($Per_Page * ($Page-1)) + 1; $j = $i; } while ($Result = mysql_fetch_array($Query)) { $user_id = $Result['user_id']; $admin_id = $Result['admin_id']; $user_name = $Result['user_name']; $user_last = $Result['user_last']; $user_add = $Result['user_add']; $admin_name = $Result['admin_name']; $admin_password = $Result['admin_password']; $status = $Result['status']; print "<tr>"; print "<td class=\"tbl1\"><div align=\"center\"><input type=\"checkbox\" name=\"chkDeluser[]\" id=\"chkDeluser$i\" value=\"$user_id\"><input type=\"hidden\" name=\"chkDeladmin[]\" id=\"chkDeladmin$i\" value=\"$admin_id\"></div></td>"; print "<td ><div align=\"center\">$i</div></td>"; print "<td > $admin_name</td>"; print "<td > $user_name $user_last</td>"; print "<td > $user_add</td>"; print "<td >"; if($status == "Admin"){ echo "<font color=\"red\">ผู้ดูแลระบบ</font>"; }else{ echo "<font color=\"red\">สมาชิก</font>"; } print "</td>"; print "<td align=\"center\"><a id=\"variousedit\" href=\"formeditmember.php?user_id=$user_id&admin_id=$admin_id\"><img src=\"images/edit.png\" width=\"16\" height=\"16\" border=\"0\"></a></td>"; print "</tr>"; $i++; } ?> <tr> <td colspan="7" align="left"> //************ส่วนที่เพิ่มเข้าไป********** <input type="hidden" name="hdnCount" value="<?php echo $i;?>"><input type="hidden" name="pageCount" value="<?php echo $Page;?>"><input type="hidden" name="perCount" value="<?php echo $Per_Page;?>"> //************ถึงแค่ตรงนี้************** <div class="pagination">ทั้งหมด: <b><?php echo $Num_Rows;?></b> แสดงหน้า: <ul> <?php if($Prev_Page){ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"prevnext\">Previous</a></li>"; } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page){ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]'>$i</a></li>"; }else{ echo "<li><a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"currentpage\">$i</a></li>"; } } if($Page!=$Num_Pages){ echo "<li><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtKeyword=$_REQUEST[txtKeyword]&rdoserach=$_REQUEST[rdoserach]' class=\"prevnext\">Next</a></li>"; } ?> </ul> </div>
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง