|
 |
|
ขอรบกวนทุกๆ ท่านแก้ไขปัญหา เรื่องการแก้ไข และบันทึก ข้อมูล หน่อยครับ ติดปัญนานแล้ว แก้ไม่ได้สักที |
|
 |
|
|
 |
 |
|
ไฟล์ที่เกี่ยวข้อง
list_addim.php
Code (PHP)
<?
/*session_start();
include "check.php";*/
include "conn.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>ระบบจองห้องประชุม สำนักงานจังหวัดลำปาง</title>
<script language="javascript" type="text/javascript">
function LogoutSystem() //ประยุกใช้เอาตามสถานการณ์นะครับ
{
parent.location.replace("login.html"); //คำสั่งที่ให้ไปยังเพจอื่นเมื่อถึงเวลาที่กำหนด ใช้แพแรนท์ตามด้วยชื่อเฟรม หากไม่มีเฟรมก็ตัดทิ้งไป แล้วทามด้วยโลเคชั่น ตามด้วยรีเพลค สาเหตุที่ใช้รีเพลคเพราะไม่ต้องการให้สามารถกดปุ่มย้อนกลับได้
}
var timer1;
function Ehandler()
{
clearTimeout(timer1);
timer1 = setTimeout("LogoutSystem()", 1000*60*10);
return true;
}
Ehandler();
if(!document.all){window.captureEvents(Event.CLICK | Event.KEYPRESS);}
window.onclick = Ehandler;
window.onkeypress = Ehandler;
</script>
<style type="text/css">
<!--
body,td,th {
font-family: MS Reference Sans Serif;
}
a {
font-family: MS Reference Sans Serif;
}
h1,h2,h3,h4,h5,h6 {
font-family: MS Reference Sans Serif;
}
.style1 {color: #990000}
.style2 {
color: #CC6600;
font-weight: bold;
}
.style7 {font-size: 14px; font-weight: bold; color: #6699CC; }
.style9 {
font-size: 14px;
color: #333333;
}
.style10 {
font-size: 14px;
color: #666666;
}
.style14 {
font-size: 13px;
color: #3399CC;
}
a:link {
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #0066CC;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.style15 {font-size: 14px}
.style17 {font-size: 14px; color: #CC3300; }
.style18 {color: #FFFFFF}
.style19 {font-size: 14px; font-weight: bold; color: #FFFFFF; }
.style21 {color: #333333}
.style23 {font-size: 14px; color: #6699FF; }
.style24 {font-size: 14px; color: #FFFFFF; }
-->
</style></head>
<body onclick="Ehandler()" onkeypress="Ehandler()">
<?
function displaydate ($x) {
$date_m=array ("ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$date_array=explode("-",$x);
$y=$date_array[0]+543;
$m=$date_array[1]-1;
$d=$date_array[2];
$m=$date_m[$m];
$displaydate="$d $m $y";
return $displaydate;
}
?>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="pic/head03.gif" width="650" height="80" border="0" /></td>
</tr>
<tr>
<td valign="middle"><table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="290" align="left" valign="middle"><span class="style1"><span class="style15">
<img src="pic/2.gif" width="20" height="29" border="0" align="absmiddle" />
<?
if ($_SESSION['level']=="1")$_SESSION['level']="ผู้ดูแลระบบ";
if ($_SESSION['level']=="2")$_SESSION['level']="ผู้ใช้ทั่วไป";
echo $_SESSION['level'];?>
</span> : <span class="style17"><?echo $_SESSION['units'];?></span></span></td>
<td width="360" height="33" align="right" valign="middle"><a href="index.php"><img src="pic/home.gif" alt="กลับสู่หน้าหลัก" width="88" height="30" border="0" align="absmiddle" /></a> <a href="logout.php"><img src="pic/logout.gif" alt="ออกจากระบบ" width="122" height="30" border="0" align="absmiddle" /></a><a href="logout.php"> </a></td>
</tr>
</table></td>
</tr>
</table>
</div></td>
</tr>
</table>
<table width="730" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="750" height="400" align="center" valign="top" background="pic/adfrm.gif"><table width="730" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" align="right" valign="bottom"><span class="style15">วันที่
<?include "date.php";?>
</span> </td>
</tr>
</table>
<table width="730" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center"><span class="style2">ข้อมูลการจองห้องประชุม</span></td>
</tr>
</table>
<table width="730" border="0" cellspacing="0" cellpadding="0">
<FORM METHOD=POST ACTION="listroom_admin.php">
<tr>
<td> </td>
</tr>
<tr>
<td align="right"><span class="style23">ค้นหาโดย
<select name="listroom" id="select">
<option value="ไม่มี">-- เลือกห้อง --</option>
<option value="1">ห้องประชุม 1</option>
<option value="2">ห้องประชุม 2</option>
<option value="3">ห้องประชุม POC</option>
</select>
<input type="submit" name="button" id="button" value="ค้นหา" />
</span> </td>
</tr>
</FORM>
</table>
<table width="730" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20"> </td>
</tr>
</table>
<table width="730" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style7 style18">จองเมื่อ</div></td>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style19">วันที่จอง</div></td>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style19">ห้อง</div></td>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style19">ช่วงเวลา</div></td>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style19">ผู้จอง</div></td>
<td height="20" valign="bottom" bordercolor="#666666" bgcolor="#666666"><div align="center" class="style19">หน่วยงาน</div></td>
<td width="50" align="center" bordercolor="#666666" bgcolor="#666666"><div align="center"><span class="style19">แก้ไข</span></div></td>
<td width="50" align="center" bordercolor="#666666" bgcolor="#666666"><div align="center"><span class="style19">ลบ</span></div></td>
</tr>
<?
$sql="SELECT * From tbres ";
$Per_Page =10;
if(!$Page)
$Page=1;
$Prev_Page = $Page-1;
$Next_Page = $Page+1;
$result = mysql_query($sql);
$Page_start = ($Per_Page*$Page)-$Per_Page;
$Num_Rows = mysql_num_rows($result);
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;
if(($Page>$Num_Pages) || ($Page<0))
print "<center><b>จำนวน $Page มากกว่า $Num_Pages ยังไม่มีข้อความ<b></center>";
$sql .="ORDER BY use_date ASC LIMIT $Page_start , $Per_Page";
$result = mysql_query($sql);
While($row= mysql_fetch_array($result))
{ $use=$row["use_date"];
$log=$row["log_date"];
$room=$row["room"];
$tm=$row["time_res"];
$res=$row["res_ing"];
$un=$row["unit"];
$use=displaydate($use);
$log=displaydate($log);
if($room=="1")$room="ห้องประชุม 1";
if($room=="2")$room="ห้องประชุม 2";
if($room=="3")$room="ห้องประชุม POC";
if( $_POST[listroom]=='1') $_POST[listroom]="ห้องประชุม 1";
if( $_POST[listroom]=='2') $_POST[listroom]="ห้องประชุม 2";
if( $_POST[listroom]=='3') $_POST[listroom]="ห้องประชุม POC";
?>
<tr onMouseOver="javascript:this.bgColor='#CCCCCC'" onMouseOut="javascript:this.bgColor=''">
<td height="20" bordercolor="#666666"><div align="center" class="style9 style10 style15"><?echo "$log";?></div></td>
<td height="20" bordercolor="#666666"><div align="center" class="style10 style15 style21"><?echo "$use";?></div></td>
<td height="20" bordercolor="#666666"><div align="center" class="style10 style15 style21"><?echo "$room";?></div></td>
<td height="20" bordercolor="#666666"><div align="center" class="style10 style15 style21"><?echo "$tm";?></div></td>
<td height="20" bordercolor="#666666"><div align="center" class="style10 style15 style21"><?echo "$res";?></div></td>
<td height="20" bordercolor="#666666"><div align="center" class="style10 style15 style21"><?echo "$un";?></div></td>
<td height="20" align="center" valign="middle" bordercolor="#666666"><a href="Edit.php?use_date=<?=$row["use_date"];?>&room=<?=$row["room"];?>&time_res=<?=$row["time_res"];?>&res_ing=<?$row["res_ing"];?>&unit=<?$row["unit"];?>">
<img src="pic/edit.gif" width="18" height="18" border="0" align="absmiddle"></a></td>
<td height="20" align="center" valign="middle" bordercolor="#666666"><a href="Del.php?use_date=<?=$row["use_date"];?>&room=<?=$row["room"];?>&time_res=<?=$row["time_res"];?>" onClick="return confirm('ยืนยันการลบข้อมูล')" ><img src="pic/del.gif" width="18" height="18" border="0" align="absmiddle"></a></td>
</tr>
<?}?>
</table>
<center> <BR>
<span class="style14">รวมทั้งหมด :
<?=$Num_Pages;?>
หน้า<BR>
<?/* สร้างปุ่มย้อนกลับ */
if($Prev_Page)
echo "<center><a href='$PHP_SELF?Page=$Prev_Page'><-- ย้อนกลับ </a>";
for($i=1; $i<$Num_Pages; $i++){
if($i != $Page)
echo "[<a href='$PHP_SELF?Page=$i'>$i</a>] ";
else
echo "$i ";
}
/*สร้างปุ่มเดินหน้า */
if($Page!=$Num_Pages)
echo " <a href ='$PHP_SELF?Page=$Next_Page'> หน้าถัดไป --> <center></a>";
echo"<center>มีจำนวนการจองใช้ $_POST[listroom] ทั้งหมด $Num_Rows รายการ </center>";
?>
</span>
</td>
</tr>
</table>
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
<tr>
<td><img src="pic/foot.gif" width="650" height="70" border="0" /></td>
</tr>
</table>
</body>
</html>
edit.php
Code (PHP)
<?
/*session_start();
include "check.php";*/
include "conn.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
<title>ระบบจองห้องประชุม สำนักงานจังหวัดลำปาง</title>
<link rel="stylesheet" type="text/css" href="epoch_styles.css" />
<script type="text/javascript" src="epoch_classes.js"></script>
<script type="text/javascript">
var bas_cal,dp_cal,ms_cal;
window.onload = function () {
dp_cal = new Epoch('epoch_popup','popup',document.getElementById('popup_container'));
};
</script>
<script language="javascript" type="text/javascript">
function LogoutSystem() //ประยุกใช้เอาตามสถานการณ์นะครับ
{
parent.location.replace("login.html"); //คำสั่งที่ให้ไปยังเพจอื่นเมื่อถึงเวลาที่กำหนด ใช้แพแรนท์ตามด้วยชื่อเฟรม หากไม่มีเฟรมก็ตัดทิ้งไป แล้วทามด้วยโลเคชั่น ตามด้วยรีเพลค สาเหตุที่ใช้รีเพลคเพราะไม่ต้องการให้สามารถกดปุ่มย้อนกลับได้
}
var timer1;
function Ehandler()
{
clearTimeout(timer1);
timer1 = setTimeout("LogoutSystem()", 1000*60*10);
return true;
}
Ehandler();
if(!document.all){window.captureEvents(Event.CLICK | Event.KEYPRESS);}
window.onclick = Ehandler;
window.onkeypress = Ehandler;
</script>
<style type="text/css">
<!--
body,td,th {
font-family: MS Reference Sans Serif;
}
a {
font-family: MS Reference Sans Serif;
}
h1,h2,h3,h4,h5,h6 {
font-family: MS Reference Sans Serif;
}
.style1 {color: #990000}
.style2 {
color: #CC3300;
font-size: 14px;
}
.style3 {font-size: 14px}
-->
</style></head>
<body onclick="Ehandler()" onkeypress="Ehandler()">
<table width="650" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><div align="center">
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="pic/head03.gif" width="650" height="80" border="0" /></td>
</tr>
<tr>
<td valign="middle"><table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="290" align="left" valign="middle"><span class="style1"><span class="style3"><img src="pic/2.gif" width="20" height="29" border="0" align="absmiddle" />
<?
if ($_SESSION['level']=="1")$_SESSION['level']="ผู้ดูแลระบบ";
if ($_SESSION['level']=="2")$_SESSION['level']="ผู้ใช้ทั่วไป";
echo $_SESSION['level'];?>
</span> : <span class="style2"><?echo $_SESSION['units'];?></span></span></td>
<td width="360" height="33" align="right" valign="middle"><a href="index.php"><img src="pic/home.gif" alt="กลับสู่หน้าหลัก" width="88" height="30" border="0" align="absmiddle" /></a> <a href="logout.php"><img src="pic/logout.gif" alt="ออกจากระบบ" width="122" height="30" border="0" align="absmiddle" /></a> </td>
</tr>
</table></td>
</tr>
</table>
</div></td>
</tr>
<tr>
<td height="400" background="body.gif"><table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="400" background="pic/body.gif"><table width="650" height="400" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="400" valign="top" background="pic/book05.gif">
<table width="650" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="25" align="right" valign="bottom"><span class="style3">วันที่
<?include "date.php";?>
</span></td>
</tr>
<tr>
<td height="20" valign="top"> </td>
</tr>
</table>
<?
$SQL = "SELECT * FROM tbres WHERE use_date = '".$_GET["use_date"]."'AND room= '".$_GET["room"]."'AND time_res= '".$_GET["time_res"]."'";
$obj = mysql_query($SQL);
$objResult = mysql_fetch_array($obj);
if(!$objResult)
{
echo "ไม่พบข้อมูล";
}
else
{
$room=$objResult["room"];
$log=$objResult["log_date"];
$use_date=$objResult["use_date"];
$time_res=$objResult["time_res"];
$res_ing=$objResult["res_ing"];
$unt=$objResult["unit"];
?>
<table width="650" height="285" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20"> </td>
<td height="20"> </td>
<td height="20"> </td>
<td height="20"> </td>
</tr>
<FORM METHOD=POST ACTION="save.php">
<tr>
<td height="25"> </td>
<td height="25"><div align="right">ห้องประชุม : </div></td>
<td height="25"><div align="left">
<select name="roomddl" size="1" id="roomddl">
<option>-- เลือกห้องประชุม --</option>
<option value="1">ห้องประชุม 1</option>
<option value="2">ห้องประชุม 2</option>
<option value="3">ห้อง POC</option>
</select>
</div></td>
<td height="25"> </td>
</tr>
<tr>
<td width="82" height="25"> </td>
<td width="249" height="25"><div align="right">วันที่ต้องการจอง : </div></td>
<td width="249" height="25"><div align="left">
<input name="txtdate" id="popup_container" type="date" size="10"/>
</div></td>
<td width="70" height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"><div align="right">ช่วงเวลา : </div></td>
<td height="25"><div align="left">
<select name="timedll" id="timedll">
<option>--เลือกช่วงเวลา --</option>
<option value="1">เช้า</option>
<option value="2">บ่าย</option>
<option value="3">เช้า - บ่าย</option>
</select>
</div></td>
<td height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"><div align="right">ชื่อผู้จอง : </div></td>
<td height="25"><div align="left">
<input name="namerestxt" type="text" size="30" value="<?=$res_ing;?>" readonly/>
</div></td>
<td height="25"> </td>
</tr>
<tr>
<td height="25"> </td>
<td height="25"><div align="right">หน่วยงาน: </div></td>
<td height="25"><div align="left"> <INPUT NAME="txtunit" TYPE="text" value="<?=$unt;?>" size="18" readonly >
</div></td>
<td height="25"> </td>
</tr>
<tr>
<td height="105"> </td>
<td height="105"> </td>
<td height="105"><div align="right">
<input type="submit" value="แก้ไข" />
<img src="pic/ok.gif" width="67" height="101" border="0" align="bottom"/></div></td>
<td height="105"> </td>
</tr>
<?}?>
</FORM>
</table>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td valign="middle"> </td>
</tr>
<tr>
<td><div align="center"><img src="pic/foot.gif" width="650" height="70" border="0" /></div></td>
</tr>
</table>
</body>
</html>
save.php
Code (PHP)
<html>
<head>
<title>ระบบจองห้องประชุม สำนักงานจังหวัดลำปาง</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$cs1 = "SET character_set_results=tis620";
mysql_query($cs1) or die('Error query: ' . mysql_error());
$cs2 = "SET character_set_client = tis620";
mysql_query($cs2) or die('Error query: ' . mysql_error());
$cs3 = "SET character_set_connection = tis620";
mysql_query($cs3) or die('Error query: ' . mysql_error());
/*
$d=date('Y-m-d');
echo "$d ";
echo "$_POST[roomddl]";
echo "$_POST[txtdate]";
echo "$_POST[timedll]";
echo "$_POST[namerestxt]";
echo "$_POST[txtunit]";
echo "$d";
*/
$objDB = mysql_select_db("test");
$strSQL = "UPDATE tbres SET ";
$strSQL .="room = '".$_POST["roomddl"]."' ";
$strSQL .=", log_date = CURDATE() ";
//$strSQL .="log_date = .CURDATE(). ";
$strSQL .=",use_date = '".$_POST["txtdate"]."' ";
$strSQL .=",time_res = '".$_POST["timedll"]."' ";
$strSQL .=",res_ing = '".$_POST["namerestxt"]."' ";
$strSQL .=",unit = '".$_POST["txtunit"]."' ";
$strSQL .=" WHERE unit = '".$_GET["unit"]."'AND res_ing= '".$_GET["res_ing"]."'";
echo "$_GET[use_date]";
//$objQuery = mysql_query($strSQL);
$objQuery = mysql_query($strSQL) or die(mysql_error());
if($objQuery)
{
echo "$strSQL";
echo "<script>
alert('บันทึกได้แล้ว');
window.location='list_admin.php';
</script>";
exit();
}
else
{
echo "<script>
alert('บันทึกไม่ได้');
window.location='list_admin.php';
</script>";
exit();
}
mysql_close($objConnect);
?>
</body>
</html>
รบช่วยผมด้วยครับ ติดมานานแล้วทำไม่ได้สักที
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-09-24 13:10:24 |
By :
oasiis |
View :
994 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1. จับ unit กับ res_ing ใส่ hidden field แล้วรับด้วย POST
2. แก้ form เป็น <FORM METHOD=POST ACTION="save.php?unit=อะไรก็ว่าไป&res_ing=อะไรก็ว่าไป">
|
 |
 |
 |
 |
Date :
2009-09-24 15:22:51 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|