|
|
|
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near 'LIMIT'. (severity 15) |
|
|
|
|
|
|
|
แบ่งหน้า ยังไงก็ไม่ออก มึนตึบ ฐานข้อมูลผมเป็น sql server ครับ ช่วยดูให้ผมที มันผิดตรงไหน Help Me Please !!
Code (PHP)
<?
include_once("conn.php");
$Per_Page = 50; // Per Page
$Page = $_GET["Page"];
if(!$_GET["Page"])
{
$Page=1;
}
$strSQL = "select prename,stf_fname+' '+stf_lname as fullname,position_id,position_name_th,postline_id,postline_name,stafftype_id,fac_name,max_edu,substafftype_id
from db_owner.data_of_person ";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
$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;
}
$strSQL .=" ORDER BY fac_name asc,fac_id asc,substafftype_id asc,stafftype_id asc,position_id desc,postline_name desc,max_edu desc LIMIT $Page_Start , $Per_Page";
$objQuery = mssql_query($strSQL);
function fullname($max_edu,$fullname,$position_name,$prename,$substafftype_id,$postline_name,$position_id)
{
if($substafftype_id==1)
{
if($max_edu==80)
{ $dr="ดร."; return $position_name." ".$dr." ".$fullname;}
else
{ return $position_name.$fullname; }
}
else
{
if($max_edu==80)
{
if($position_id <> "00")
{ $dr="ดร.";
return $position_name." ".$dr." ".$fullname;
}
else
{
return $dr." ".$fullname;
}
}
else
{
if($position_id <> "00")
{
return $position_name.$fullname;
}
else
{
return $prename.$fullname;
}
}
}
}
function positionwork($substafftype_id,$postline_name,$position_name)
{
if($substafftype_id==1)
{
return $position_name;
}
else
{
return $postline_name;
}
}
?>
<tr>
<td><div align="right">
<div align="center">
<div align="center">
<div align="center">
<div align="center">
<table >
<tr >
<td><table>
<tr>
<td>ที่</div></td>
<td >
<div align="left">ชื่อ-นามสกุล</div>
</div></td>
<td> </td>
<td><div align="center" class="style18">
<div align="left">ตำแหน่ง</div>
</div></td>
<td> </td>
<td><div align="center" class="style18">
<div align="left">สังกัด</div>
</div></td>
</tr>
<?
$i = 1;
if($Page > 1)
{
$i = ($Per_Page * ($Page-1)) + 1;
}
while($rss=mssql_fetch_array($objQuery))
{
?>
<tr>
<td><div align="center" class="style48">
<?=$i;?>
</div></td>
<td><div align="left"><span class="style48">
<?=fullname($rss["max_edu"],$rss["fullname"],$rss["position_name_th"],$rss["prename"],$rss["substafftype_id"],$rss["postline_name"],$rss["position_id"]);?>
</span> </div></td>
<td> </td>
<td><div align="left"><span class="style48">
<?=positionwork($rss["substafftype_id"],$rss["postline_name"],$rss["position_name_th"]);?>
</span></div></td>
<td> </td>
<td><div align="left"><span class="style48">
<?=$rss["fac_name"];?>
</span></div></td>
</tr>
<?
$i++;
}
?>
</table>
<br />
<p align="center" class="style45">
Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page :
<?
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> ";
}
mssql_close($objConnect);
?> </table>
Tag : PHP, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2012-07-13 15:02:08 |
By :
compiak |
View :
2005 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เดี๋ยวผมจะลองดูครับ
|
|
|
|
|
Date :
2012-07-13 15:35:40 |
By :
compiak |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|