 |
สอบถามปัญหา การแบ่งหน้าตารางเวลาค้นหา ข้อมูลไม่show |
|
 |
|
|
 |
 |
|
<table border="1" align="center" width="508">
<tr>
<td colspan ="12"width="auto" height="auto" colspan=2 bgcolor="#6495ED" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFA500"></font><font face="Microsoft Sans Serif" Size="3" color="#000000">เอกสารเวียน</font></b></span></td>
</tr>
<tr>
<td width="30" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">ลำดับ</font></b></span></td>
<td width="150" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">ชื่อเรื่อง</font></b></span></td>
<td width="45" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">เอกสารเลขที่</font></b></span></td>
<td width="100" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">Files เอกสาร</font></b></span></td>
<td width="90" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">วันที่รับ/นำส่งเอกสาร</font></b></span></td>
<td width="90" height="20" colspan=1 bgcolor="#FFFAFA" bordercolor="#FFFFFF" align="center"> <span lang="th" <b>
<font face="Microsoft Sans Serif" Size="2" color="#FFFFFF"></font><font face="Microsoft Sans Serif" Size="2" color="#000000">วันที่เอกสารเข้า</font></b></span></td>
</tr>
<?php
include("utility.php");
connect_db();
$sqlshow = "SELECT
`tbldocument`.`doc_code`, `tbldocument`.`doc_item`,
`tbldocument`.`doc_detail`, `tbldocument`.`doc_date`,
`tbldocument`.`doc_dateAcc`, `tbldocument`.`doc_depart`,
`tbldocument`.`doc_part`, `tbldocument`.`doc_name`,
`tbldocument`.`doc_newname`, `tbldocument`.`group_code`,
`tbldocument`.`type_code`, `tbldocument`.`head_code`, `tblgroup`.`group_name`,
`tbltype`.`type_name`, `tblhead`.`head_name`
FROM
`tbldocument` INNER JOIN
`tblhead` ON `tblhead`.`head_code` = `tbldocument`.`head_code` INNER JOIN
`tbltype` ON `tbltype`.`type_code` = `tbldocument`.`type_code` INNER JOIN
`tblgroup` ON `tblgroup`.`group_code` = `tbldocument`.`group_code`
WHERE
`tbldocument`.`group_code` = '$txtselect1' AND
`tbldocument`.`type_code` = '$txtselect2' AND
`tbldocument`.`head_code` LIKE '%$txtselect3%' AND
`tbldocument`.`doc_item` LIKE '%$nameno%' AND
`tbldocument`.`doc_detail` LIKE '%$name%' ";
$queryt = mysql_query ($sqlshow) or die (mysql_error());
$Num_Rows = mysql_num_rows($queryt);
$Per_Page = 2;
$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;
}
$offset=($Page-1)*$Per_Page;
$count=$offset;
$sqlshow = "SELECT
`tbldocument`.`doc_code`, `tbldocument`.`doc_item`,
`tbldocument`.`doc_detail`, `tbldocument`.`doc_date`,
`tbldocument`.`doc_dateAcc`, `tbldocument`.`doc_depart`,
`tbldocument`.`doc_part`, `tbldocument`.`doc_name`,
`tbldocument`.`doc_newname`, `tbldocument`.`group_code`,
`tbldocument`.`type_code`, `tbldocument`.`head_code`, `tblgroup`.`group_name`,
`tbltype`.`type_name`, `tblhead`.`head_name`
FROM
`tbldocument` INNER JOIN
`tblhead` ON `tblhead`.`head_code` = `tbldocument`.`head_code` INNER JOIN
`tbltype` ON `tbltype`.`type_code` = `tbldocument`.`type_code` INNER JOIN
`tblgroup` ON `tblgroup`.`group_code` = `tbldocument`.`group_code`
WHERE
`tbldocument`.`group_code` = '$txtselect1' AND
`tbldocument`.`type_code` = '$txtselect2' AND
`tbldocument`.`head_code` LIKE '%$txtselect3%' AND
`tbldocument`.`doc_item` LIKE '%$nameno%' AND
`tbldocument`.`doc_detail` LIKE '%$name%'
ORDER BY
`tbldocument`.`doc_date` DESC LIMIT $Page_Start , $Per_Page";
$queryt = mysql_query($sqlshow);
if($queryt=='0')
{ echo"ยังไม่มีข้อมูลในส่วนนี้"; }
else
while($objResult = mysql_fetch_array($queryt))
{
$count++;
if($bg == "#87CEFA")
{
$bg = "#FFE4B5";
}
else
{
$bg = "#87CEFA";
}
?>
<tr bgcolor="<?=$bg?>">
<td height="25" align="center" valign="middle"><font face="Microsoft Sans Serif" Size="2" color="#000000"><?=$count?></font></td>
<td><right><font face="Microsoft Sans Serif" Size="2" color="#000000"><?=$objResult["doc_detail"];?></font></center></td>
<td><center><font face="Microsoft Sans Serif" Size="2" color="#000000"><?=$objResult["doc_item"];?></font></center></td>
<td><center><font face="Microsoft Sans Serif" Size="2" color="#000000"><a href="turn/<?=$objResult["doc_newname"];?>"><?=$objResult["doc_newname"];?></a></font></center></td>
<td><center><font face="Microsoft Sans Serif" Size="2" color="#000000"><?=$objResult["doc_dateAcc"];?></font></center></td>
<td><center><font face="Microsoft Sans Serif" Size="2" color="#000000"><?=$objResult["doc_date"];?></font></center></td>
</tr>
<?
}
?>
</table>
<br>
<font face="Microsoft Sans Serif" size="2" color="#330000"><b>Total </b><?= $Num_Rows;?> <b>Record</b> : <?=$Num_Pages;?> <b>Page</b> </font>
<?
if($Prev_Page)
{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><< Back</a>";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i'>$i</a></font> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
?>
รบกวนหน่อยค่ะ
ข้อมูลที่ ค้นหามาได้ มี 6 record 3 page คือ show หน้าละ 2 record หน้าแรก ถูกต้อง แต่พอคลิก หน้าที่2 ปรากฎว่า ข้อมูลที่ค้นหามาได้ข้างต้นหายหมด ดิฉันต้องการให้ คลิก หน้า2 หรือ3 ข้อมูลยังอยู่ ใครช่วยได้บ้างจาก code ข้างต้น
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2011-01-11 16:07:12 |
By :
พัด |
View :
928 |
Reply :
2 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันจะต้องส่งค่าไปด้วยครับ เช่น
Code (PHP)
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&xx=xx&xxx=xxx'>Next>></a> ";
แล้วดึงค่า $_GET มาใช้ครับ
Go to : PHP MySQL Search Record Paging/Pagination
|
 |
 |
 |
 |
Date :
2011-01-11 16:22:29 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$sqlshow = "SELECT
`tbldocument`.`doc_code`, `tbldocument`.`doc_item`,
`tbldocument`.`doc_detail`, `tbldocument`.`doc_date`,
`tbldocument`.`doc_dateAcc`, `tbldocument`.`doc_depart`,
`tbldocument`.`doc_part`, `tbldocument`.`doc_name`,
`tbldocument`.`doc_newname`, `tbldocument`.`group_code`,
`tbldocument`.`type_code`, `tbldocument`.`head_code`, `tblgroup`.`group_name`,
`tbltype`.`type_name`, `tblhead`.`head_name`
FROM
`tbldocument` INNER JOIN
`tblhead` ON `tblhead`.`head_code` = `tbldocument`.`head_code` INNER JOIN
`tbltype` ON `tbltype`.`type_code` = `tbldocument`.`type_code` INNER JOIN
`tblgroup` ON `tblgroup`.`group_code` = `tbldocument`.`group_code`
WHERE
`tbldocument`.`group_code` = '$txtselect1' AND
`tbldocument`.`type_code` = '$txtselect2' AND
`tbldocument`.`head_code` LIKE '%".$_GET[txtselect3]."%' AND
`tbldocument`.`doc_item` LIKE '%".$_GET[nameno]."%' AND
`tbldocument`.`doc_detail` LIKE '%".$_GET[name]."%'
ORDER BY
`tbldocument`.`doc_date` DESC LIMIT $Page_Start , $Per_Page";
ส่วนคิวรี่
Code (PHP)
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtselect3=$_GET[txtselect3]&nameno=$_GET[nameno]&name=$_GET[name]'>Next>></a> ";
ก็ดึง $_GET มาแล้วก็ยังไม่ได้ ค่ะคุณ วิน
|
 |
 |
 |
 |
Date :
2011-01-12 10:21:28 |
By :
พัด |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|