|
|
|
แบ่งหน้าทำไงคับ ช่วยดูให้ที่ แบ่งแล้วหน้าที่สอง ไม่แสดง PHP, Ms SQL Server 2008 |
|
|
|
|
|
|
|
Code (PHP)
<table width='95%' align="center">
<tr>
<td align="center" class="style2">
<h2 class="style2 style3">สรุปข้อมูลนักศึกษา</h2>
<p class="style3 style2"> </p>
<form action="" method="post" enctype="multipart/form-data" name="FrmR" class="style2" id="FrmR" >
<span class="style2"> ตั้งแต่ปี :
<label>
<?
$yearStart = date("Y") - 10;
$yearEnd = date("Y");
echo "<select name=\"year1\">\n";
echo "<option value=\"\">- - Year - -</option>\n";
for($i = $yearStart;$i<=$yearEnd;$i++){
$y=$i+543;
echo "<option value=\"$y\">".($i+543)."</option>\n";
}
echo "</select>\n";
?>
</label>
ถึงปีที่:
<?
$yearStart = date("Y") - 10;
$yearEnd = date("Y");
echo "<select name=\"year2\">\n";
echo "<option value=\"\">- - Year - -</option>\n";
for($i = $yearStart;$i<=$yearEnd;$i++){
$y=$i+543;
echo "<option value=\"$y\">".($i+543)."</option>\n";
}
echo "</select>\n";
?>
<label></label>
</span>
<input class="button" type="submit" name="SubReoprt" value="รายงาน" />
</form> </td>
</tr>
<tr>
<td class="style2"></td>
</tr>
</table>
<hr align="center" width="100%" size="10" noshade="noshade" color="#0099FF" />
<p class="style2">
<?
include("../User_Function/all_function.php");
$date1=$_POST['year1'];
$date2=$_POST['year2'];
if($date1!='' ||$date2!='' ){
$strSQL = "SELECT * FROM $tb_Students where Year between '$date1' and '$date2' ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
$num=1;
$Per_Page =30 ; // 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;
}
?>
</p>
<table width="101%" border="1" align="center" bordercolor="#0099FF">
<tr>
<th width="22%" bgcolor="#00CCFF" class="style2"> <div align="center" class="style4">รหัสนักศึกษา</div></th>
<th width="31%" bgcolor="#00CCFF" class="style2"><div align="center"><span class="style4">ชื่อ - สกุล</span></div></th>
<th width="29%" bgcolor="#00CCFF" class="style2"><div align="center">สาขา</div></th>
<th width="18%" bgcolor="#00CCFF" class="style2"><div align="center">ปีการศึกษา</div></th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
$ID_stu=mssql_result($objQuery,$i,"ID_stu");
$ID_stu2=mssql_result($objQuery,$i,"ID_stu2");
$Prefix=mssql_result($objQuery,$i,"Prefix");
$Fname=mssql_result($objQuery,$i,"Fname");
$Lname=mssql_result($objQuery,$i,"Lname");
$Branch=mssql_result($objQuery,$i,"Branch");
$Year=mssql_result($objQuery,$i,"Year");
?>
<tr>
<td class="style2"><div align="left">
<div align="center">
<?=$ID_stu2;?>
</div>
</div></td>
<td class="style2"><div align="center">
<a href="detail_students.php?ID_stu=<?=$ID_stu;?>"><?=$Prefix;?>
<?=$Fname;?>
<?=$Lname;?></a></div></td>
<td class="style2"><div align="center">
<?=$Branch;?>
</div></td>
<td class="style2"><div align="center"><?=$Year;?></div></td>
</tr>
<?
}
?>
</table>
<span class="style2"><br />
</span><span class="style2">
จำนวน
<?= $Num_Rows;?>
คน : จำนวนทั้งหมด
<?=$Num_Pages;?>
หน้า :
<?
if($Prev_Page)
{
echo " <a href='$_SERVER[SCRIPT_NAME]?year1=$date1&year2=$date2&Page=$Prev_Page'><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[<a href='$_SERVER[SCRIPT_NAME]?year1=$date1&year2=$date2&Page=$i'>$i</a>]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?year1= $date1&year2=$date2&Page=$Next_Page'>Next>></a> ";
}
?>
<? }//////ปิด if post?>
Tag : PHP, Ms SQL Server 2008
|
|
|
|
|
|
Date :
2011-05-02 01:07:57 |
By :
jakkapang |
View :
939 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|