|
|
|
รบกวนขอโค้ด Refresh ไปที่หน้า page หน้าถัดไปอัตโนมัติหน่อยค่ะ |
|
|
|
|
|
|
|
ตัวอย่าง Code
Code (PHP)
<!DOCTYPE html>
<html>
<head>
<title>ตาราง Talk</title>
</head>
<body>
<table style="width:90%" align="center">
<tr bgcolor="#ff9900">
<th width="15%">เวลาออกอากาศ</th>
<th width="20%">รายการ</th>
<th width="15%">ช่อง</th>
<th width="30%">สินค้า</th>
<th width="20%">ราคา</th>
</tr>
<?php
$sql= "SELECT convert(date,starttime) as StartDate,convert(varchar(5),starttime,108) as StartTime,convert(varchar(5),endtime,108) as EndTime,convert(varchar(5),starttime,108)+'-'+convert(varchar(5),endtime,108) as period,program_group,channel,ItemName,cost FROM Test
WHERE starttime >= DATEADD(hh,-1,getdate()) and starttime <= DATEADD(hh,+2,getdate()) ORDER BY starttime";
$result = mssql_query($sql);
$Num_Rows = mssql_num_rows($result);
$Per_Page = 15; // กำหนดจำนวนเรคอร์ดที่ต้องการแสดงผลใน 1 หน้า
$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;
}
for($i=$Page_Start;$i<$Page_End;$i++) {
//while($arr = mssql_fetch_array($result)){
$StartDate = date('d-m-Y',strtotime(mssql_result($result ,$i,"StartDate")));
$StartTime = mssql_result($result ,$i,"StartTime");
$EndTime = mssql_result($result ,$i,"EndTime");
$period = mssql_result($result ,$i,"period");
$program_group = iconv("windows-874","UTF-8",mssql_result($result ,$i,"program_group"));
$channel = iconv("windows-874","UTF-8",mssql_result($result ,$i,"channel"));
$ItemName = iconv("windows-874","UTF-8",mssql_result($result ,$i,"ItemName"));
$cost =mssql_result($result ,$i,"cost");
?>
<tr bgcolor="#fff9f0">
<td align="center"><?=$period ;?></span></td>
<td align="center"><?=$program_group;?></td>
<td align="center"><?=$channel;?></td>
<td align="center"><?=$ItemName;?></td>
<td align="center"><?=number_format($cost);?></td>
</tr>
<? }?>
<tr bgcolor="#ff9900">
<td colspan="5" align="right" class="text4">Total <?=number_format($Num_Rows);?> Record (s) : <?=$Num_Pages;?> Page (s) :
<?
if($Prev_Page)
{
echo "<a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'><span class ='text3'><< Back </span></a>";
}
?>
<select name="Paging" onChange="MM_jumpMenu('parent',this,0)">
<?
for($i=1; $i<=$Num_Pages; $i++){
if($i == $Page)
{
$sel = "selected";
}
else
{
$sel = "";
}
?>
<option value="<?=$_SERVER[SCRIPT_NAME];?>?Page=<?=$i?>"<?=$sel;?>><?=$i;?></option>
<?
}
?>
</select>
<?
if($Page!=$Num_Pages)
{
echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'><span class ='text3'>Next>></span></a> ";
}
?>
</td>
</tr>
</table>
</head>
</body>
</html>
|
|
|
|
|
Date :
2017-04-10 10:55:50 |
By :
kungjung |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|