|
|
|
PHP เปลี่ยนหน้าแล้วผล Result หายทำไงดีคับ ช่วยผมด้วย |
|
|
|
|
|
|
|
PHP ผมมันไม่ยอมแสดงผลของ Result ต่อ พอกด Next หรือ กดเลขหน้าอื่นๆ ทำไงดีอ่ะคับ นี้เป็นโค๊ดที่รุ่นพี่ผมจำมานะคับ แล้วผมหาจุดแก้ไม่เจอ
Code (PHP)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>ลูกค้าโครงการจ้างตัวแทนจำหน่ายสินค้าและบริการ</title>
</head>
<body bgcolor=#8593e3>
<?include("function/topmenu.php");?><BR>
<?
$keep_Service=$_POST["Service"];
$keep_Sector=$_POST["Sector"];
$keep_Payee=$_POST["Payee"];
//echo $keep_Sector;
//echo $keep_Service;
//echo $keep_Payee;
?>
<!--************************************************************FORM**************************************************************-->
<CENTER><TABLE width="600">
<TR height="120">
<TD bgcolor=#eaeaea>
<FONT SIZE="3"><CENTER><B>โครงการจ้างตัวแทนจำหน่ายสินค้าและบริการ</B></CENTER></FONT>
<CENTER><form name="frmSearch" method="post" action="<?=$_SERVER['SCRIPT_NAME'];?>" onSubmit="return allSelect();">
<!-- <CENTER><form name="frmSearch" method="post" action="<? print($_SERVER['PHP_SELF']); ?>" onSubmit="return allSelect();"> -->
<TABLE width="500" BORDER=1 RULES=NONE FRAME=BOX>
<TR>
<TD width="150"><FONT SIZE="2">ส่วนงาน</FONT> </TD>
<TD width="350">
<select name="Sector" id="Sector" style="width:200px">
<option value="999">- ทั้งหมด -</option>
<?
include("connectdb/connect_10057159.php");
$strSQL1="SELECT DISTINCT Sector
FROM [skndata].[dbo].[Emp_Dealer]";
$objQuery1 = mssql_query($strSQL1) or die ("Error Query [".$strSQL1."]");
while($result1=mssql_fetch_array($objQuery1)){
?>
<option value="<?=$result1[Sector];?>" <?if($keep_Sector==$result1[Sector]){ echo "SELECTED";}?>><?=$result1[Sector];?></option>
<?
}
?>
</select>
</TD>
</TR>
<TR>
<TD><FONT SIZE="2">ผู้รับเงิน</FONT> </TD>
<TD>
<select name="Payee" id="Payee" style="width:200px">
<option value="999">- ทั้งหมด -</option>
<?
include("connectdb/connect_10057159.php");
$strSQL2="SELECT DISTINCT Payee
FROM [skndata].[dbo].[Emp_Dealer]
WHERE Payee <> ''";
$objQuery2 = mssql_query($strSQL2) or die ("Error Query [".$strSQL2."]");
while($result2=mssql_fetch_array($objQuery2)){
?>
<option value="<?=$result2[Payee];?>" <?if($keep_Payee==$result2[Payee]){ echo "SELECTED";} ?>><?=$result2[Payee];?></option>
<?
}
?>
</select>
</TD>
</TR>
<TR>
<TD colspan="2"><CENTER><FONT SIZE="2"><input type="submit" value="ค้นหา"></FONT></CENTER></TD>
</TR>
</TABLE>
</CENTER>
<div align=right><FONT SIZE="2">Managed By สขน.</FONT></div>
</TD>
</TR>
</TABLE>
</TABLE></CENTER>
<!--************************************************************QUERY**************************************************************-->
<?
IF(($keep_Sector != "999")||($keep_Payee != "999"))
{ IF(($keep_Sector != "999")&&($keep_Payee != "999"))
{
//include("connectdb/connect_10057159.php");
$objConnect = mssql_connect("10.0.57.159","sa","oF,9yllt") or die("Error Connect to Database");
$objDB = mssql_select_db("skndata");
$strSQL= "SELECT *
FROM Emp_Dealer
WHERE Sector='$keep_Sector' AND Payee='$keep_Payee'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
}
ELSE {IF($keep_Sector != "999")
{
//include("connectdb/connect_10057159.php");
$objConnect = mssql_connect("10.0.57.159","sa","oF,9yllt") or die("Error Connect to Database");
$objDB = mssql_select_db("skndata");
$strSQL= "SELECT *
FROM Emp_Dealer
WHERE Sector='$keep_Sector'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
}
ELSE {IF ($keep_Payee != "999")
//include("connectdb/connect_10057159.php");
$objConnect = mssql_connect("10.0.57.159","sa","oF,9yllt") or die("Error Connect to Database");
$objDB = mssql_select_db("skndata");
$strSQL= "SELECT *
FROM Emp_Dealer
WHERE Payee='$keep_Payee'";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
}
}
}
ELSE IF(($keep_Sector = "999")&&($keep_Payee = "999"))
{ //include("connectdb/connect_10057159.php");
$objConnect = mssql_connect("10.0.57.159","sa","oF,9yllt") or die("Error Connect to Database");
$objDB = mssql_select_db("skndata");
$strSQL= "SELECT *
FROM Emp_Dealer";
$objQuery = mssql_query($strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mssql_num_rows($objQuery);
}
?>
<!--************************************************************PAGE CAL**************************************************************-->
<center><table width="1050" BORDER=0>
<tr><td width="">
<?
$Per_Page = 100; // Per Page
$keeplist=$_GET["searchlist"];
$keepresult=$_GET["resultlist"];
$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++){?>
<!--************************************************************PAGE NUMBER**************************************************************-->
<FONT SIZE="2">Total <?= $Num_Rows;?> Record | <?=$Num_Pages;?> Page | </FONT>
<?
if($Prev_Page)
{
echo " <FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'><< Back</a></FONT> ";
}
if($Num_Pages<=10){
for($j=1; $j<=$Num_Pages; $j++)
{
if($j != $Page){
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$j&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$j</a></FONT>]";
}
else
{
echo "<FONT SIZE=2><b> $j </b></FONT>";
}
}
}
else{
if($Page-5 > 0){
$p01=$Page-4;
$p02=$Page-3;
$p03=$Page-2;
$p04=$Page-1;
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p01&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p01</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p02&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p02</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p03&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p03</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p04&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p04</a></FONT>] ";
}
echo "<FONT SIZE=2><b> $Page </b></FONT>";
if($Page+5 < $Num_Pages){
$p06=$Page+1;
$p07=$Page+2;
$p08=$Page+3;
$p09=$Page+4;
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p06&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p06</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p07&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p07</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p08&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p08</a></FONT>] ";
echo "[<FONT SIZE=2><a href='$_SERVER[SCRIPT_NAME]?Page=$p09&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>$p09</a></FONT>] ";
}
}
if($Page!=$Num_Pages)
{
echo " <FONT SIZE=2><a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&searchlist=$keeplist&txtKeyword=$_GET[txtKeyword]&resultlist=$keepresult'>Next>></a></FONT> ";
}
?>
</td>
<!--************************************************************EXCEL**************************************************************-->
<TD width="500">
<?
//$file = "monumtemp/monum";
//$filName = $file."_".date("Y-m-d_H-i-s",time()).".csv";
//$objWrite = fopen($filName, "w");
//fwrite($objWrite, "\"หมายเลขโทรศัพท์\",\"ศูนย์บริการ\",\"ส่วนงาน\",\"ข้อมูลเดิม\",\"ชื่อผู้ติดต่อเดิม\",\"Case\",\"ชื่อผู้ติดต่อ 1\",\"มือถือ 1\",\"ชื่อผู้ติดต่อ 2\",\"มือถือ 2\",\"ชื่อผู้ติดต่อ 3\",\"มือถือ 3\",\"โทรศัพท์\",\"ผลการ Cleansing\"\n");
//while($objResult = mssql_fetch_array($objQuery)){
// fwrite($objWrite, "\"'$objResult[telno]\",\"$objResult[Location_Abbr]\",\"$objResult[Sector]\",\"'$objResult[tel_contact]\",\"'$objResult[cust_ori]\",\"$objResult[case1]\",\"$objResult[name1]\",\"'$objResult[mobile1]\",\"$objResult[name2]\",\"'$objResult[mobile2]\",\"$objResult[name3]\",\"'$objResult[mobile3]\",\"'$objResult[ftel1]\",\"$objResult[Result]\"\n");
//}
//fclose($objWrite);
echo "<div align=right><FONT SIZE=2><B><a href=$filName>Download File (.csv)</a><BR></B></FONT></div>";
?>
</td></tr></table></center>
<!--************************************************************TABLE**************************************************************-->
<CENTER><table width="" BORDER=1 RULES=ALL FRAME=BOX>
<tr bgcolor="#003366">
<th width="50"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">ส่วนงาน</div></FONT></th>
<th width="100"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">เลขหมาย</div></FONT></th>
<th width="100"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">ประเภทบริการ</div></FONT></th>
<th width="200"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">ชื่อลูกค้า</div></FONT></th>
<th width="375"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">ผู้รับเงิน</div></FONT></th>
<th width="50"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">จำนวนเงิน (บาท)</div></FONT></th>
<th width="150"> <FONT SIZE="2" COLOR="#FFFFFF"><div align="center">วัน/เดือน/ปี ทีจ่ายเงิน</div></FONT></th>
</tr>
<?
for($i=$Page_Start;$i<$Page_End;$i++)
{
?>
<tr bgcolor=#FFFFFF>
<td><FONT SIZE="2"><A HREF="Emp_Dealerdetail.php/?Service=<?=mssql_result($objQuery,$i,"Service");?>&Tel=<?=mssql_result($objQuery,$i,"Tel");?>&Name_Customer=<?=mssql_result($objQuery,$i,"Name_Customer");?>&Payee=<?=mssql_result($objQuery,$i,"Payee");?>&Amount_Pay=<?=mssql_result($objQuery,$i,"Amount_Pay");?>&Date_Pay=<?=mssql_result($objQuery,$i,"Date_Pay");?>"><div align="center"><?=mssql_result($objQuery,$i,"Sector");?></div></A></FONT></td>
<td><FONT SIZE="2"><div align="center"><?=mssql_result($objQuery,$i,"Tel");?></div></FONT></td>
<td><FONT SIZE="2"><?=mssql_result($objQuery,$i,"Service");?></FONT></td>
<td><FONT SIZE="2"><?=mssql_result($objQuery,$i,"Name_Customer");?></FONT></td>
<td><FONT SIZE="2"><?=mssql_result($objQuery,$i,"Payee");?></FONT></td>
<td><FONT SIZE="2"><div align="right"><?=mssql_result($objQuery,$i,"Amount_Pay");?></div></FONT></td>
<td><FONT SIZE="2"><div align="center"><?=mssql_result($objQuery,$i,"Date_Pay");?></div></FONT></td>
</tr>
<?
}
?>
</table></CENTER>
<!--************************************************************END TABLE**************************************************************-->
<?
mssql_close($objConnect);
}
?>
</body>
</html>
Tag : PHP, Ms SQL Server 2008
|
|
|
|
|
|
Date :
2012-11-28 09:42:35 |
By :
MoNKEY-ToPBY |
View :
1016 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code เยอะแบบนี้คงจะหายากน่ะครับ
|
|
|
|
|
Date :
2012-11-28 09:53:52 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ผมเลยจนปัญญา เลยต้องมาโพสต์ถามเนี่ยแหละคับ T^T
|
|
|
|
|
Date :
2012-11-28 09:57:07 |
By :
MoNKEY-ToPBY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณเริ่มต้นจากยาก มันก็เลยเป็นแบบนี้แหละครับ การเขียนโปรแกรมที่ดี จะต้องค่อย ๆ เขียนแล้วค่อย รัน ปรับแต่งไปเรื่อย ๆ ครับ เวลาเจอปัญหามันจะได้หาจุดที่มีปัญหาง่ายครับ
|
|
|
|
|
Date :
2012-11-28 10:00:05 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำไงได้อ่ะคับพี่เค้าบอกให้เอามาแก้ให้เป็นอีกอันผมก็ต้องทำ T^T
|
|
|
|
|
Date :
2012-11-28 10:02:12 |
By :
MoNKEY-ToPBY |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|