|
|
|
รบกวนช่วยดูโค้ดแบ่งหน้าให้หน่อยน่ะค่ะ ปัญหาคือ เมื่อคลิกหน้า 2 แล้วมีข้อมูลเหมือนเดิมค่ะ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
include('../config.inc.php');
connectdb();
mysql_select_db($dbname,$conn);
if(isset($_SESSION["userN"])) {//อ่านค่า session
//>>>>>>>>> Add On
$Per_Page =10;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$sql = "SELECT
`member`.`fname`,
`service`.`s_id`,
`service`.`s_cause`,
`dep`.`dep_name`
FROM
`service`
Inner Join `member` ON `member`.`emp_id` = `service`.`em_id`
Inner Join `dep` ON `dep`.`dep_id` = `service`.`dep_id` ";
$dbquery=mysql_query($sql);
$num_row = mysql_num_rows($dbquery);
$Page_start = ($Per_Page*$Page)-$Per_Page;
if($num_row<=$Per_Page){
$Num_Pages =1;
}else if(($num_row % $Per_Page)==0){
$Num_Pages =($num_row/$Per_Page) ;
}else{
$Num_Pages =($num_row/$Per_Page) +1;
}
$Num_Pages = (int)$Num_Pages;
if(($Page>$Num_Pages) || ($Page<0)){
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
}
//>>>>>>>>>>>
if (isset($_GET['fix'])){
$s_id = $_GET['s_id'];
$sql = "UPDATE service SET status_work='3' WHERE s_id='{$s_id}';";
mysql_query($sql) or die(mysql_error());
echo "
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-874\">
<SCRIPT LANGUAGE=\"JavaScript\">
alert('ปรับสถานะเสร็จแล้ว');
location.href = 'form_service_list.php';
</SCRIPT> ";
exit();
} // if (isset($_GET['fix'])){
if (isset($_REQUEST['iSearch'])) $iSearch = $_REQUEST['iSearch'];
else $iSearch = "";
$condition = "WHERE {$iSearch} LIKE '%{$iSearch}%' ";
$sql="select * from service {$condition} order by s_id asc";
$dbquery=mysql_query($sql);
?>
<html><!-- InstanceBegin template="/Templates/newcontrol3.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>รายละเอียดการขอซ่อม</title>
<meta http-equiv="refresh" content="30">
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<script language="JavaScript" type="text/JavaScript">
function save(object) {
if (confirm("ต้องการบันทึกข้อมูลนี้หรือไม่") == true) {
return true;
}
return false;
}
function del(object) {
if (confirm("ต้องการลบข้อมูลนี้หรือไม่") == true) {
return true;
}
return false;
}
function logout(object) {
if (confirm("ต้องการออกจากระบบหรือไม่") == true) {
return true;
}
return false;
}
</script>
<!-- InstanceBeginEditable name="head" --><!-- InstanceEndEditable -->
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0">
<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td valign="top" class="left"><div align="center">
<table width="90%" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#FFFFFF">
<td height="16" valign="middle"><img src="../images/banner.jpg" width="1000" height="180"></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="20" bgcolor="4E89D9"><div align="right"><a title="Sign out" href="logout.php" onClick="return logout()"><img src="images/posts_locked.gif" width="18" height="18" border="0">ออกจากระบบ</a>
</div></td>
</tr>
<tr bgcolor="#FFFFFF">
<td height="14" bgcolor="7AACE9"> </td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="2" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="210" height="490" valign="top" bgcolor="F5F5F5" class="corn22">
<br> <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="11"><img src="images/h1.gif" width="11" height="8"></td>
<td background="images/h2.gif"><img src="images/h2.gif" width="2" height="8"></td>
<td width="11"><img src="images/h3.gif" width="11" height="8"></td>
</tr>
<tr>
<td background="images/h4.gif"><img src="images/h4.gif" width="11" height="3"></td>
<td valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="260" valign="top" bgcolor="#FFFFFF">
<table width="96%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''">
<td><a href="../admin/main.php"><img src="images/icon_home.gif" width="16" height="16" border="0"></a>
<a href="main.php"> หน้าหลัก </a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><a href="form_service_list.php"> <img src="../icon/Address_Book.png" width="15" height="15"> รับแจ้งงาน
MIS </a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><img src="images/ico-user_group.gif" width="16" height="16">
<a href="form_em_list.php"> ข้อมูลพนักงาน</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><img src="images/posts_locked.gif" width="18" height="18">
<a href="form_dep_list.php"> ข้อมูลแผนก</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><img src="images/Icon-cpu.gif" width="16" height="19">
<a href="form_arai_list.php">
ข้อมุลอะไหล่</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><img src="images/Icon-cpu.gif" width="16" height="19"> <a href="form_type_arai_list.php">ประเภทอะไหล่</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><img src="images/ico-file_edit.gif" width="16" height="16">
<a href="form_manu.php"> ข้อมูลคุรุภัณฑ์</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td height="24"><img src="icon/Tools.png" width="15" height="15"> <a href="form_faq_list.php">FAQ</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td height="21"><img src="icon/Folder.png" width="15" height="15"> <a href="form_manu_report.php">รายงานการปฏิบัติงาน</a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
<tr class="bg1" onMouseOver="this.style.backgroundColor='#EAEAEA'" onMouseOut="this.style.backgroundColor=''" >
<td><a title="Sign out" href="../logout.php" onClick="return logout()"><img src="images/posts_locked.gif" width="18" height="18" border="0"></a>
<a href="logout.php" onClick="return logout()">Logout </a></td>
</tr>
<tr>
<td height="1" bgcolor="#CACACA" class="dot"></td>
</tr>
</table>
<br>
</td>
</tr>
</table></td>
<td background="images/h5.gif"><img src="images/h5.gif" width="11" height="3"></td>
</tr>
<tr>
<td><img src="images/h6.gif" width="11" height="15"></td>
<td background="images/h7.gif"><img src="images/h7.gif" width="5" height="15"></td>
<td><img src="images/h8.gif" width="11" height="15"></td>
</tr>
</table>
<br> <br> <br> <br> <br> <br> </td>
<td width="10" valign="top" background="images/left_bg.gif"> </td>
<td width="680" height="480" valign="top"> <table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2"> </td>
<td> </td>
</tr>
</table>
<!-- InstanceBeginEditable name="EditRegion3" -->
<form method="post" action="" name="form1" onSubmit=""></form>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="98" height="35" valign="middle" bgcolor="DDEEFF"><div align="center"><img src="../images/last1.gif" width="86" height="28"></div></td>
<td bgcolor="DDEEFF"><div align="left"> ฟอร์มรับแจ้งงานซ่อม</div></td>
</tr>
</table>
<br>
<table width="96%" border="0" align="center" cellpadding="5" cellspacing="0">
<?
$condition = "";
$status_work = "";
$status_need = "";
$iSearch = "";
if (isset($_REQUEST['search'])){
$status_work = $_REQUEST['status_work'];
$status_need = $_REQUEST['status_need'];
$iSearch = $_REQUEST['iSearch'];
$condition = "WHERE service.status_work LIKE '%$status_work%' AND service.status_need LIKE '%$status_need%' AND service.s_id LIKE '%$iSearch%' ";
} // if (isset($_REQUEST['search'])){
$sql = "select * from service {$condition} order by status_work asc, s_id desc";
$dbquery=mysql_query($sql);
$num_row = mysql_num_rows($dbquery);
//echo $sql;
$sql2 = "SELECT service.*,dep.dep_name,member.fname FROM service INNER JOIN dep ON service.dep_id = dep.dep_id ";
$sql2 = $sql2." INNER JOIN member ON service.em_id = member.emp_id {$condition} ORDER BY status_work asc, service.s_id ";
$sql2 = sql2." LIMIT $Page_start , $Per_Page ";// <<<<<<<<<<<<<<Add on
$dbquery2= mysql_query($sql2);
@$num_rows2 = mysql_num_rows($dbquery2);
?>
<tr>
<td height="20" valign="top" bgcolor="#9EAAFF"><form name="form2" method="post" action="">
<table border="0">
<tr>
<td>สถานะการซ่อม</td>
<td>
<select name="status_work" id="status_work">
<option value="" <?=($status_work=="" ? "selected" : "")?>>แสดงทั้งหมด</option>
<option value="0" <?=($status_work=="3" ? "selected" : "")?>>ซ่อมไม่ได้</option>
<option value="0" <?=($status_work=="0" ? "selected" : "")?>>รอยืนยัน</option>
<option value="1" <?=($status_work=="1" ? "selected" : "")?>>ดำเนินการ</option>
<option value="2" <?=($status_work=="2" ? "selected" : "")?>>สำเร็จ</option>
</select>
</td>
<td><input type="submit" name="search" id="search" value="ค้นหา"></td>
</tr>
<tr>
<td>ประเภทความต้องการ</td>
<td>
<input type="radio" name="status_need" id="status_need" value="" <?=($status_need=="" ? "checked" : "")?>> ทั้งหมด
<input type="radio" name="status_need" id="status_need" value="1" <?=($status_need=="1" ? "checked" : "")?>> ด่วน
<input type="radio" name="status_need" id="status_need" value="0" <?=($status_need=="0" ? "checked" : "")?>> ปกติ
</td>
<td></td>
</tr>
<tr>
<td>ค้นหารหัสขอซ่อม</td>
<td><input name="iSearch" type="text" id="iSearch" value="<?=$iSearch?>" size="15"> </td>
<td></td>
</tr>
</table>
</form>
</td>
</tr>
<tr>
<td height="120" colspan="2" valign="top"> <div align="center">
<form method="post" action="./form_service_delete.php" name="mylist" onSubmit="return del()">
<TABLE width="100%" border=1 align="center" cellPadding=2 cellSpacing=0 borderColor=#d9d9d9
borderColorLight=#d9d9d9
borderColorDark=#ffffff>
<tr bgcolor="F5F5F5" >
<td width="23"> <div align="center">
</div></td>
<td width="84"> <div align="center">รหัสขอซ่อม</div></td>
<td width="244"> <div align="center">รายการซ่อม</div></td>
<td width="107"><div align="center">ชื่อผู้ขอ</div></td>
<td width="91"><div align="center">แผนก</div></td>
<td width="129"><div align="center">สถานะงานซ่อม</div></td>
</tr>
<?php
//While ($Recs <= $Pagesize) {
// $row = mysql_fetch_array($dbquery2);
$Recs = 0;
$Gopage= 1;
$Pagesize = 10;
$Checkpage = 1;
$Maxcount = 1;
$Scriptname = $_SERVER['PHP_SELF'];
$Pagesize = 1;
$Script_Name = $Scriptname;
$num_rows = $num_rows2;
While ($row = mysql_fetch_array($dbquery)) {
$service_id = $row['s_id'];
$s_cause = $row['s_cause'];
$dep_name = $row['dep_name'];
$emp_name = $row['fname'];
?>
<tr bgcolor="ffffff" onMouseOver="this.style.backgroundColor='#ffffee'" onMouseOut="this.style.backgroundColor=''" >
<td> <div align="center">
<input name="<?php echo $service_id;?>" type="checkbox" id="$id" onClick="CCA(this)">
</div></td>
<td> <div align="center"><?php echo $service_id;?></div></td>
<td> <div align="left"></div> <a href="javascript:MM_openBrWindow('form_service_detail.php?id=<?=$service_id?>','','width=450,height=350, scrollbars=1')"><?php echo $s_cause;?></a> </td>
<td><? echo $row['fname']; ?></td>
<td> <?php echo $dep_name;?> </td>
<td><div align="left">
<input name="st_w" type="checkbox" id="st_w" disabled value="<? echo $service_id;?>" <? if($row['status_work']==0){ echo "checked";}?> > <!--onClick="ChangeST(this.value,0);-->
รอยืนยัน <Br />
<input name="st_w" type="checkbox" id="st_w" <?=(($row['status_work']==0) ? "onClick=\"return doFixed('form_service_list.php?fix=no&s_id=$service_id','','width=900,height=1000,scrollbars=1');\" " : 'disabled')?> value="<? echo $service_id;?>" <? if($row['status_work']==3){ echo "checked";}?> >
ซ่อมไม่ได้ <br />
<input name="st_w" type="checkbox" id="st_w" <?=(($row['status_work']==0) ? "onClick=\"javascript:MM_openBrWindow('form_service_admin_detail.php?a_id=$service_id','','width=900,height=1000,scrollbars=1');\" " : 'disabled')?> value="<? echo $service_id;?>" <? if($row['status_work']==1){ echo "checked";}?> > <!--onClick="ChangeST(this.value,1);--> <!--onClick="ChangeST(this.value,1);-->
ดำเนินการ <br />
<input name="st_w" type="checkbox" id="st_w" <?=(($row['status_work']==1) ? "onClick=\"location.href='form_service_use_arai.php?a_id=$service_id'\" " : 'disabled')?> value="<? echo $service_id;?>" <? if($row['status_work']==2){ echo "checked";}?> >
<!--onClick="ChangeST(this.value,2);-->เสร็จเรียบร้อย</div></td>
</tr>
<?php
echo "<? echo (($Gopage-1)*$Pagesize)+$Recs; ?>";
$Recs++;
}
if($num_rows2 <1) { ?>
<tr <?php if($Recs % 2 !=1) { echo "class = 'RAD'";}?> onMouseOver="this.style.backgroundColor='#ffffee'" onMouseOut="this.style.backgroundColor=''">
<td height="40" colspan="11"><div align="center">-
ไม่มีข้อมูล - </div></td>
</tr>
<?php
}
?>
</table>
<SCRIPT language="JavaScript">
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
function CheckAll() {
for (var i=0;i< document.mylist.elements.length; i++)
{
var e =document.mylist.elements[i];
if (e.name != "allchk")
e.checked = document.mylist.allchk.checked;
}
}
function CCA(CB,noHL){
if(!noHL) {
if(CB.checked)
hL(CB);
else
dL(CB);
}
}
function hL(E) {
while (E.tagName !="TR") { E=E.parentElement; }
E.className = "H";
}
function dL(E,S) {
while (E.tagName != "TR") { E=E.parentElement;}
if (typeof(S) !="undefined")
E.className=S;
else
E.className="";
}
function doFixed(url){
if (confirm("คุณต้องการกำหนดสถานะการซ่อมเป็นซ่อมไม่ได้ใช่หรือไม่?")){
//return true;
location.href = url;
}else{
return false;
}
} // function doFixed(url){
</SCRIPT>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" valign="bottom"><input name="Submit" type="submit" value="ลบข้อมูล" ></td>
</tr>
</table>
</form>
<div align="left">
<Script language="JavaScript">
var frm = document.mylist;
</SCRIPT>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td>มีทั้งหมดจำนวน<? echo $Num_Rows;?> หน้า: <b> <? echo $Num_Pages;?> </b> หน้า :
<? /* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo " <a href='$PHP_SELF?Page=$Prev_Page'><< Prev </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i'>$i</a>]";
else
echo "<b> $i </b>";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo "<a href ='$PHP_SELF?Page=$Next_Page'> Next >></a>";
?></td>
</tr>
</table>
</div>
</div></td>
</tr>
</table>
<!-- InstanceEndEditable --></td>
</tr>
</table>
</td>
</tr>
<tr bgcolor="94B8EC">
<td width="165" height="24"><div align="center"> </div></td>
<td><div align="center"> Copyright 2010<strong> The Peace Canning (1958) Co., Ltd</strong>. All Rights Reserved.</div></td>
</tr>
</table>
<br>
</div>
</td>
</tr>
</table>
</body>
<!-- InstanceEnd --></html>
<script language="JavaScript">
function ChangeST(s_id,type)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
document.getElementById("src").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","change_st.php?id="+s_id+"&type="+type,true);
xmlhttp.send();
Reload();
}
function Reload(){
window.location.reload();
//document.form1.submit();
}
</script>
<?
disconnectdb();
}
else{
echo "<script language='javascript'> ";
echo "alert('กรุณา Login เพื่อทำรายการ ');";
echo "window.location.href =\"../index.php\";";
echo "</script>";
}
?>
Tag : PHP
|
|
|
|
|
|
Date :
2011-07-06 16:37:57 |
By :
kikikaro871 |
View :
905 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
echo "<a href ='$PHP_SELF?Page=$Next_Page'> Next >></a>";
คุณจะต้องส่งค่าสำหรับ Search ไปด้วยครับ
|
|
|
|
|
Date :
2011-07-06 17:12:57 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขอบคุณมากๆๆค่ะ^^
|
|
|
|
|
Date :
2011-07-07 08:48:38 |
By :
kikikaro871 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|