|
|
|
ช่วยดูโค้ดทีค่ะ ต้องการแบ่งหน้าเว็บ แต่มันติดตรงที่ว่าถ้ามีโค้ดค้นหาด้วย มันนับจำนวนทั้งหมดในฐานข้อมูล |
|
|
|
|
|
|
|
แหะๆๆๆ....ทำเป็นโปรเจ็คจบหน่ะค่ะ >.<
ทำได้แล้ว..ขอบคุณค่ะ -*- ใส่ผิดที่นี่เอง ไปใส่ด้านหน้า Page ซะงั้น 555+
|
|
|
|
|
Date :
2012-04-03 07:20:07 |
By :
Witchloves |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โค้ดที่แก้แล้วค่ะ
Code (PHP)
<?php
require("../inc/connect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" >
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="../css/b_style.css">
<script type="text/javascript">
<!--
function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
</head>
<link rel="stylesheet" type="text/css" href="../css/page.css">
<body>
<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" valign="top" bgcolor="#1A58A3"><p align="left">
<a name="top" id="top"></a></td>
</tr>
<tr>
<td colspan="2" valign="top" bgcolor="#1F5FA9"> </td>
</tr>
<tr>
<td height="23" colspan="2" valign="middle" background="../images/button/six_2.gif" bgcolor="#17191A"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="3%"> </td>
<td width="97%" ></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#F0F0F0"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" valign="top"><br />
<table width="98%" border="0" cellpadding="1" cellspacing="1">
<tr>
<td width="50%"><form id="form1" method="post" action="">
สถานะผู้ดูแล<span class="style24">
<select name="st" class="txtbox" onchange="MM_jumpMenu('parent',this,0)" id="st">
<option value="<?=$_SERVER['../bf/PHP_SELF'];?>">ทั้งหมด</option>
<?
$sql_group = "select * from status";
$dbquery_group = mysql_query($sql_group);
$num_rows_group = mysql_num_rows($dbquery_group);
while ($result_group = mysql_fetch_array($dbquery_group))
{
if($_GET["status_id"] == $result_group["status_id"])
{
$sel="selected";
}
else
{
$sel="";
}
?>
<option value="<?=$_SERVER['../bf/PHP_SELF'];?>?status_id=<?=$result_group["status_id"];?>" <?=$sel;?>>
<?=$result_group["status_name"];?>
</option>
<?
}
?>
</select>
</form>
</td>
<td width="50%" align="right" class="add_link"><div align="right"><a href="../bf/bf_admin_add.php"><img src="../images/Add-icon.png" alt="" width="32" height="32" border="0" />เพิ่ม Admin</a></div></td>
</tr>
</table>
<table width="98%" border="0" cellpadding="1" cellspacing="1" bordercolor="#1F5FA9" class="stb">
<tr>
<td width="5%" align="center" valign="top" bgcolor="#C4DBF4"><div align="center">ลำดับ</div></td>
<td width="13%" align="center" valign="top" bgcolor="#C4DBF4"><div align="center">Username</div></td>
<td width="27%" align="center" valign="top" bgcolor="#C4DBF4">ชื่อ-นามสกุล</td>
<td width="28%" align="center" valign="top" bgcolor="#C4DBF4"><div align="center">Email</div></td>
</tr>
<?
$condition="";
if($_GET["status_id"] <> "")
{
$condition="and status_id='$_GET[status_id]' ";
}
$strSQL = "SELECT * FROM admin ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysql_num_rows($objQuery);
$stages = 3; // ...
$Per_Page = 1; // 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;
}
$LastPagem1 = $Num_Pages-1;
$strSQL .=" Where 1 $condition order by admin_id ASC LIMIT $Page_Start , $Per_Page";
$objQuery = mysql_query($strSQL);
$no = 0;
if($Page > 1)
{
$no = ($Per_Page*$Page)-$Per_Page;
}
while($result = mysql_fetch_array($objQuery))
{
$no++;
?>
<tr>
<td align="center" valign="top"><?=$no;?></td>
<td align="left" valign="top"><?=$result["admin_uname"];?></td>
<td align="left" valign="top"><?=$result["admin_name"];?>
<?=$result["admin_lname"];?></td>
<td align="left" valign="top"><?=$result["admin_email"];?></td>
</tr>
<? } ?>
</table>
<br />
<table width="60%" border="0" cellpadding="0" cellspacing="0" class="page_link">
<tr>
<td align="left">
<?=$_SERVER['PHP_SELF'];?>?status_id="<?=$_GET[status_id]?>";
<?
if($Num_Pages > 1){
echo "<div class='paginate'>";
//First Pages
if($Page > 1)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=1&status_id=$_GET[status_id]'>หน้าแรก</a> ";
}else {
echo " <span class='disabled'>หน้าแรก</span> ";
}
//Previous
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&status_id=$_GET[status_id]'>ย้อนกลับ</a> ";
}else {
echo " <span class='disabled'>ย้อนกลับ</span> ";
}
// ...
if ($Num_Pages < 7 + ($stages * 2)) // Not enough pages to breaking it up
{
// Pages
for($i=1; $i<=$Num_Pages; $i++){
if($i == $Page)
{
echo "<b> <span class='current'>$i </span></b>";
}else{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$i&status_id=$_GET[status_id]'>$i</a>";
}
}
}else if($Num_Pages > 5 + ($stages * 2)) { // Enough pages to hide a few?
// Beginning only hide later pages
if($Page < 1 + ($stages * 2)){
for ($i = 1; $i < 4 + ($stages * 2); $i++)
{
if ($i == $Page){ echo "<b> <span class='current'>$i </span></b>";
}else{ echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$i&status_id=$_GET[status_id]'>$i</a>";
}
}
echo "...";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$LastPagem1&status_id=$_GET[status_id]'>$LastPagem1</a>";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Num_Pages&status_id=$_GET[status_id]'>$Num_Pages</a>";
// Middle hide some front and some back
}else if($Num_Pages - ($stages * 2) > $Page && $Page > ($stages * 2)){
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=1&status_id=$_GET[status_id]'>1</a>";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=2&status_id=$_GET[status_id]'>2</a>";
echo "...";
for ($i = $Page - $stages; $i <= $Page + $stages; $i++)
{
if ($i == $Page){
echo "<b> <span class='current'>$i </span></b>";
}else{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$i&status_id=$_GET[status_id]'>$i</a>";
}
}
echo "...";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$LastPagem1&status_id=$_GET[status_id]'>$LastPagem1</a>";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Num_Pages&status_id=$_GET[status_id]'>$Num_Pages</a>";
// End only hide early pages
}else{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=1&status_id=$_GET[status_id]'>1</a>";
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=2&status_id=$_GET[status_id]'>2</a>";
echo "...";
for ($i = $Num_Pages - (2 + ($stages * 2)); $i <= $Num_Pages; $i++)
{
if ($i == $Page){
echo "<b> <span class='current'>$i </span></b>";
}else{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$i&status_id=$_GET[status_id]'>$i</a>";
}
}
}}
// Next
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&status_id=$_GET[status_id]'>หน้าถัดไป</a> ";
}else {
echo " <span class='disabled'>หน้าถัดไป</span> ";
}
// Last Pages
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Num_Pages&status_id=$_GET[status_id]'>ไปหน้าสุดท้าย</a> ";
}else {
echo " <span class='disabled'>ไปหน้าสุดท้าย</span> ";
}
echo"</div>"; }
?></td>
</tr>
</table>
<br /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="24" valign="middle" background="../images/button/six_2.gif" bgcolor="#0B4B95" class="text_link"><div align="center"><a href="#top" >กลับขึ้นไปด้านบน</a></div></td>
</tr>
<tr>
<td valign="top" bgcolor="#0B4B95"> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>
|
|
|
|
|
Date :
2012-04-03 09:11:07 |
By :
Witchloves |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|