|
|
|
ช่วยผมหน่อยครับ แบ่งหน้า ด้วย dreamwever ให้มันนับ record 1 2 3 |
|
|
|
|
|
|
|
ตรงลำดับที่อะครับ อยากให้มันนับ 1 2 3 4 5 ถ้านับหน้าเดียวมันนับให้ได้ แต่พอแบ่ง หน้าแล้วมันไม่นับต่อครับ
Code (PHP)
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_tmb = $_GET['number'];
$pageNum_tmb = 0;
if (isset($_GET['pageNum_tmb'])) {
$pageNum_tmb = $_GET['pageNum_tmb'];
}
$startRow_tmb = $pageNum_tmb * $maxRows_tmb;
mysql_select_db($database_conhos, $conhos);
$query_tmb = "SELECT pt.hn,vn.pdx,vn.dx0,vn.dx1,vn.dx2,vn.dx3,vn.dx4,vn.dx5,concat(pt.pname,pt.fname,' ',pt.lname) AS ptname,concat(pt.addrpart,' ','หมู่',' ',pt.moopart,' ',th.full_name) AS address FROM patient pt left outer join vn_stat vn ON vn.hn=pt.hn left outer join thaiaddress th ON th.addressid=vn.aid WHERE pt.tmbpart='$keywords' and pt.amppart=$amp and pt.chwpart=$chw and (vn.pdx in($htt) or vn.dx0 in($htt) or vn.dx1 in($htt) or vn.dx2 in($htt) or vn.dx3 in($htt) or vn.dx4 in($htt) or vn.dx5 in($htt)) GROUP BY pt.hn ORDER BY pt.hn ASC";
$query_limit_tmb = sprintf("%s LIMIT %d, %d", $query_tmb, $startRow_tmb, $maxRows_tmb);
$tmb = mysql_query($query_limit_tmb, $conhos) or die(mysql_error());
$row_tmb = mysql_fetch_assoc($tmb);
if (isset($_GET['totalRows_tmb'])) {
$totalRows_tmb = $_GET['totalRows_tmb'];
} else {
$all_tmb = mysql_query($query_tmb);
$totalRows_tmb = mysql_num_rows($all_tmb);
}
$totalPages_tmb = ceil($totalRows_tmb/$maxRows_tmb)-1;
$queryString_tmb = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_tmb") == false &&
stristr($param, "totalRows_tmb") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_tmb = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_tmb = sprintf("&totalRows_tmb=%d%s", $totalRows_tmb, $queryString_tmb);
?><!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>
<style type="text/css">
<!--
.style1 {
font-family: Tahoma;
font-size: 12px;
color: #0000FF;
font-weight: bold;
}
.style2 {
font-family: Tahoma;
font-size: 12px;
}
body {
background-image: url(../image/bg.gif);
}
.style3 {
font-family: Tahoma;
font-size: 14px;
color: #FF0000;
font-weight: bold;
}
.style5 {font-family: Tahoma; font-size: 12px; color: #0000FF; }
.style6 {
font-family: Tahoma;
font-size: 14px;
color: #FF0000;
}
-->
</style>
<script type="text/javascript">
<!--
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
//-->
</script>
</head>
<body>
<span class="style3">คำค้น
<?php echo $keywords; ?></span> <span class="style3">ทั้งหมด <?php echo $totalRows_tmb ?> รายการ</span> <br />
<table width="100%" border="1" cellspacing="0" bordercolor="#FFFFCC">
<tr>
<td width="5%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">ลำดับที่</div></td>
<td width="11%" bordercolor="#FFFAFA" background="../image/orange_004.jpg"><div align="center" class="style1">HN</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">pdx</div></td>
<td width="7%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx0</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx1</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx2</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx3</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx4</div></td>
<td width="6%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">dx5</div></td>
<td width="15%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">ชื่อ</div></td>
<td width="26%" bordercolor="#FFFAFA" background="../image/orange_004.jpg" class="style1"><div align="center">ที่อยู่</div></td>
</tr>
<?php do {
//$i1 = 1;
$p++;
$i++;
if($i%2==0)
{
$bg = "#FAEBD7";
}
else
{
$bg = "#FFF8DC";
}
?>
<?php if ($totalRows_tmb > 0) { // Show if recordset not empty ?>
<tr bgcolor="<?=$bg;?>">
<td bordercolor="#FFFAFA"><div align="center" class="style2"><?=$p;?></div></td>
<td bordercolor="#FFFAFA"><div align="center" class="style2"><?php echo $row_tmb['hn']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['pdx']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx0']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx1']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx2']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx3']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx4']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"><div align="center"><?php echo $row_tmb['dx5']; ?></div></td>
<td bordercolor="#FFFAFA" class="style2"> <?php echo $row_tmb['ptname']; ?></td>
<td bordercolor="#FFFAFA" class="style2"> <?php echo $row_tmb['address']; ?></td>
</tr>
<?php } // Show if recordset not empty ?>
<?php
// $p++;
if($pageNum_tmb >0)
{
$p=$pageNum_tmb +1;
}
} while ($row_tmb = mysql_fetch_assoc($tmb));
$i1 = 1;
?>
</table>
<span class="style6">
<?php if ($totalRows_tmb == 0) { // Show if recordset empty ?>
ไม่มีข้อมูลที่คุณต้องการครับ
<?php } // Show if recordset empty ?>
</span><br />
<span class="style5">หน้าที่ <?php echo ($pageNum_tmb+1); ?> ทั้งหมด <?php echo $totalPages_tmb; ?> หน้า รายการที่ <?php echo ($startRow_tmb + 1) ?> ถึง <?php echo min($startRow_tmb + $maxRows_tmb, $totalRows_tmb) ?> ทั้งหมด <?php echo $totalRows_tmb ?> </span> <span class="style5">รายการ</span><br />
<table border="0" align="center">
<tr>
<td><?php if ($pageNum_tmb > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_tmb=%d%s", $currentPage, 0, $queryString_tmb); ?>"><img src="../image/frist.gif" width="32" height="32" border="0" title="หน้าแรก"/></a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_tmb > 0) { // Show if not first page ?>
<a href="<?php printf("%s?pageNum_tmb=%d%s", $currentPage, max(0, $pageNum_tmb - 1), $queryString_tmb); ?>"><img src="../image/previwe.gif" width="32" height="32" border="0" title="ย้อนกลับ" /></a>
<?php } // Show if not first page ?> </td>
<td><?php if ($pageNum_tmb < $totalPages_tmb) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_tmb=%d%s", $currentPage, min($totalPages_tmb, $pageNum_tmb + 1), $queryString_tmb); ?>"><img src="../image/Next.gif" width="32" height="32" border="0" title="ถัดไป" /></a>
<?php } // Show if not last page ?> </td>
<td><?php if ($pageNum_tmb < $totalPages_tmb) { // Show if not last page ?>
<a href="<?php printf("%s?pageNum_tmb=%d%s", $currentPage, $totalPages_tmb, $queryString_tmb); ?>"><img src="../image/Last.gif" width="32" height="32" border="0" title="หน้าสุดท้าย" /></a>
<?php } // Show if not last page ?> </td>
</tr>
</table>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2012-05-31 09:49:13 |
By :
addy_it |
View :
975 |
Reply :
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เข้าดูไม่ได้...
|
|
|
|
|
Date :
2012-05-31 10:07:31 |
By :
addy_it |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แก้ Link ให้ใหม่แล้วครับ
|
|
|
|
|
Date :
2012-05-31 10:16:20 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมอยากจะปรับใช้กับโค้ดข้างบนอะครับ ผมลองดูตาม link หลายรอบแลว้ครับ ผมปรับไม่ได้ ครับ
|
|
|
|
|
Date :
2012-05-31 10:19:32 |
By :
addy_it |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ใช้ ดรีมสร้างดูอยากนะครับโค้ดยาวเป็นเบือ ใช้ jquery ช่วยง่ายกว่า
|
|
|
|
|
Date :
2012-05-31 14:16:52 |
By :
keng_ds |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เฮ้อ !!!
|
|
|
|
|
Date :
2012-05-31 14:19:34 |
By :
addy_it |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|