อยากทราบว่าผมใช้ SQL Server 2008 ทำ Search Paging ร่วมกับ Ajax ไม่ได้เหรอครับ
ดัดแปลงละครับ Error เลย
Warning : mssql_query() [function.mssql-query ]: message: Incorrect syntax near 'province'. (severity 15) in C:\AppServ\www\1799\setting\province.php on line 97
Warning : mssql_query() [function.mssql-query ]: Query failed in C:\AppServ\www\1799\setting\province.php on line 97
Error Query [SELECT * FROM province order by PROVINCE_IDselect province order by PROVINCE_ID ASC 0 , 25]
Code (PHP)
$strPage = $_POST["myPage"];
$strSQL = "SELECT * FROM province order by PROVINCE_ID";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
$Per_Page = 25; // Per Page
$Page = $strPage;
if(!$strPage)
{
$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;
}
?>
<?
$strSQL .="select province order by PROVINCE_ID ASC $Page_Start , $Per_Page";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<form method="POST" name="frmMain" action="province_delete.php" onSubmit="return onDelete();">
<input type="hidden" name="hdnCount" value="<?=$s;?>">
<center>
<table border="0" bordercolor="blue" cellspacing="0" class="style3" width="100%">
<tr bgcolor="blue" class="style1">
<th width="10%" align="center"><input type="image" src="delete.png" name="btnDelete" value="Delete" alt="ลบ" width="20" height="20"></th>
<th width="10%" align="center">รหัสจังหวัด</th>
<th width="300"align="center">ชื่อจังหวัด</th>
<th width="10%" align="center">แก้ไข</th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<?if($bg == "white")
{
$bg = "#CCCCCC";
} else {
$bg = "white";
}
?>
<tr bgcolor="<?=$bg?>">
<td align="center" ><input type="checkbox" name="chkDel[]" id="chkDel<?=$s;?>" value="<?=mssql_result($objQuery,$i,"PROVINCE_ID");?>"></td>
<td align="center"><?=mssql_result($objQuery,$i,"PROVINCE_CODE");?></div></td>
<td><?=mssql_result($objQuery,$i,"PROVINCE_NAME");?></td>
<td align="center"><a onclick='window.open("province_edit.php?Pro_1=<?=mssql_result($objQuery,$i,"PROVINCE_ID");?>",null, "height=400,width=400,status=yes,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0")' href="#">แก้ไข</td>
</tr>
<?
}
?>
</table>
<br />
มีทั้งหมด
<b><?= $Num_Rows;?></b>
เรคคอร์ด:
<b><?=$Num_Pages;?></b>
หน้า : อยู่หน้าที่
<?
if($Prev_Page)
{
echo " <a href=\"JavaScript:doCallAjax('$Prev_Page')\"><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href=\"JavaScript:doCallAjax('$i')\">$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href=\"JavaScript:doCallAjax('$Next_Page')\">Next >></a> ";
}
?>
ประวัติการแก้ไข 2011-07-19 09:18:15 2011-07-19 09:20:59
Date :
2011-07-19 09:17:38
By :
MyZeus
กลับไปดูตัวอย่างใหม่ครับ
Date :
2011-07-19 09:22:19
By :
webmaster
แก้ละครับ มันไม่ยอมเปลี่ยนหน้า
Code (PHP)
$strPage = $_POST["myPage"];
$strSQL = "SELECT * FROM province order by PROVINCE_ID";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
$Per_Page = 25; // 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;
}
?>
<form method="POST" name="frmMain" action="province_delete.php" onSubmit="return onDelete();">
<input type="hidden" name="hdnCount" value="<?=$s;?>">
<center>
<table border="0" bordercolor="blue" cellspacing="0" class="style3" width="100%">
<tr bgcolor="blue" class="style1">
<th width="10%" align="center"><input type="image" src="delete.png" name="btnDelete" value="Delete" alt="ลบ" width="20" height="20"></th>
<th width="10%" align="center">รหัสจังหวัด</th>
<th width="300"align="center">ชื่อจังหวัด</th>
<th width="10%" align="center">แก้ไข</th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<?if($bg == "white")
{
$bg = "#CCCCCC";
} else {
$bg = "white";
}
?>
<tr bgcolor="<?=$bg?>">
<td align="center" ><input type="checkbox" name="chkDel[]" id="chkDel<?=$s;?>" value="<?=mssql_result($objQuery,$i,"PROVINCE_ID");?>"></td>
<td align="center"><?=mssql_result($objQuery,$i,"PROVINCE_CODE");?></div></td>
<td><?=mssql_result($objQuery,$i,"PROVINCE_NAME");?></td>
<td align="center"><a onclick='window.open("province_edit.php?Pro_1=<?=mssql_result($objQuery,$i,"PROVINCE_ID");?>",null, "height=400,width=400,status=yes,toolbar=0,menubar=0,scrollbars=1,resizable=1,status=1,location=0")' href="#">แก้ไข</td>
</tr>
<?
}
?>
</table>
<br />
มีทั้งหมด
<b><?= $Num_Rows;?></b>
เรคคอร์ด:
<b><?=$Num_Pages;?></b>
หน้า : อยู่หน้าที่
<?
if($Prev_Page)
{
echo " <a href=\"JavaScript:doCallAjax('$Prev_Page')\"><< Back</a> ";
}
for($i=1; $i<=$Num_Pages; $i++){
if($i != $Page)
{
echo "[ <a href=\"JavaScript:doCallAjax('$i')\">$i</a> ]";
}
else
{
echo "<b> $i </b>";
}
}
if($Page!=$Num_Pages)
{
echo " <a href=\"JavaScript:doCallAjax('$Next_Page')\">Next >></a> ";
}
?>
</form>
<?
mssql_close($objConnect);
?>
Date :
2011-07-19 09:36:13
By :
MyZeus
เงียบอีกแล้ววว - -*
Date :
2011-07-19 16:20:05
By :
MyZeus
ช่วยดูให้หน่อยนะครับ
Date :
2011-07-19 21:05:59
By :
MyZeus
....
Date :
2011-07-20 07:20:32
By :
MyZeus
Load balance : Server 03