|
 |
|
โค้ดการแบ่งหน้า............พอกดหน้าถัดไปข้อมูลกลับไม่เเสดงทั้งที่มีข้อมูลอยู่ค่ะ.................. |
|
 |
|
|
 |
 |
|
หนูเขียนโค้ดการแบ่งหน้าตามลิงค์ด้านล่างนี่เเล้วค่ะ
https://www.thaicreate.com/php/php-oracle-list-record-paging.html
ผลลัพท์ที่ออกมาหลังจากการรัน

มีข้อมูลอยู่ทั้งหมด 5 แถว แต่พอคลิ๊กหน้าที่ 2 กลับไม่มีอะไรค่ะ ตามภาพด้านล่างนี่ค่ะ
โค้ดที่ทำอยู่ด้านล่างนี่ค่ะ หนูทำตามลิงค์ข้างบนแล้วแต่ไม่เข้าใจว่าเวลากดหน้าถัดไปกลับไม่มีข้อมูลค่ะทั้งๆที่ข้อมูลมี

Code (PHP)
<html>
<head>
<title></title>
</head>
<body>
<?php
$year=$_POST['year'];
$term=$_POST['term'];
$faculty=$_POST['faculty'];
?>
ปีการศึกษา <?=$year;?>ภาคเรียนที่<?=$term;?>คณะ<?=$faculty;?>
<?
include("connect.php");
$strSQL = "SELECT LOANS.\"student_id\",LOANS.\"year_loans\",STUDENT.\"prefix\",STUDENT.\"name_stud\",STUDENT.\"surname_stud\",STUDENT.\"program_name\",STUDENT.\"faculty_name\"
FROM LOANS,STUDENT where LOANS.\"student_id\"=STUDENT.\"student_id\" AND LOANS.\"year_edu\"='$year' AND LOANS.\"term\"='$term' AND STUDENT.\"faculty_name\"='$faculty' ORDER BY LOANS.\"year_loans\" ASC ";
$objParse = oci_parse ($objConnect, $strSQL);
oci_execute ($objParse,OCI_DEFAULT);
$Num_Rows = oci_fetch_all($objParse, $Result);
$Per_Page = 2; // 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;
}
$Page_End = $Per_Page * $Page;
IF ($Page_End > $Num_Rows)
{
$Page_End = $Num_Rows;
}
?>
<table width="1053" border="0" align="center">
<tr align="center" bgcolor="#CCCCCC">
<th width="110"> <div align="center">รหัสนักศึกษา</div></th>
<th width="200"> <div align="center">ชื่อ</div></th>
<th width="200"> <div align="center">นามสกุล</div></th>
<th width="53"> <div align="center">ชั้นปีที่</div></th>
<th width="184"> <div align="center">โปรแกรม</div></th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<tr>
<td align="center">
<?=$Result["student_id"][$i];?>
</td>
<td><?=$Result["prefix"][$i];?>
<?=$Result["name_stud"][$i];?></td>
<td><?=$Result["surname_stud"][$i];?></td>
<td align="center"><?=$Result["year_loans"][$i];?></td>
<td align="left"><?=$Result["program_name"][$i];?></td>
</tr>
<?
}
?>
</table>
<br>
ทั้งหมด
<?= $Num_Rows;?> แถว : <?=$Num_Pages;?> หน้า :
<?
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> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>Next>></a> ";
}
oci_close($objConnect);
?>
</body>
</html>
Tag : PHP, Oracle

|
|
 |
 |
 |
 |
Date :
2012-01-31 21:12:38 |
By :
banana_bnn |
View :
1422 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ใสตรงไหนค่ะพี่วิน.........................
|
 |
 |
 |
 |
Date :
2012-01-31 22:26:35 |
By :
banana_bnn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ยังไม่ได้ค่ะพี่วิน..................รบกวนอีกนิดค่ะ
|
 |
 |
 |
 |
Date :
2012-01-31 22:49:15 |
By :
banana_bnn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|