|
|
|
php mysql หน้า update ข้อมูลมันไม่บันทึกอ่ะครับ ช่วยดูให้หน่อยครับ |
|
|
|
|
|
|
|
Code หน้าsave
<?
$id_edit=$_POST[id_edit];
$job_status=$_POST[job_status];
$job_result=$_POST[job_result];
$job_ansname=$_POST[job_ansname];
$job_success=$_POST[job_success];
$job_remark=$_POST[job_remark];
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
$objDB = mysql_select_db("request");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$sql="update job set job_status='$job_status',job_result='$job_result',job_ansname='$job_ansname', job_success='$job_success',job_remark='$job_remark' where job_id='$id_edit'";
echo $sql;
$result=mysql_db_query($dbname,$sql);
if($result){
echo"<H3>Complete</H3>";
}else{
echo"<H3>ERROR:Sorry</H3>";
}
mysql_close();
?>
Code หน้าแสดงข้อมูล
<?
session_start();
if($_SESSION['id'] == "")
{
echo "<center>Please Login! </center>";
echo"<meta http-equiv=\"REFRESH\" content =\"2; URL=../index.php\"> ";
exit();
}
if($_SESSION['status'] != "ADMIN")
{
echo "This page for Admin only!";
echo"<meta http-equiv=\"REFRESH\" content =\"2; URL=../index.php\"> ";
exit();
}
$now = time(); // checking the time now when home page starts
if($now > $_SESSION['expire'])
{
session_destroy();
echo "<script language='javascript'>alert('ใช้งานระบบเกินเวลาที่กำหนดกรุณา login ใหม่อีกครั้ง!');</script>";
print"<meta http-equiv=refresh content=1;URL=../index.php> ";
}
mysql_connect("localhost","root","1234");
mysql_select_db("request");
mysql_query("SET NAMES tis620");
mysql_query("SET NAMES UTF8");
$strSQL = "SELECT * FROM admin WHERE id = '".$_SESSION['id']."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
?>
<?
$idedit=$_GET[id_edit];
include"connect.php";
//$sql="select * from job where job_id='$id_edit'";
$sql="select job.job_id,job.per_id,job.job_fnameth,job.job_lnameth,job.job_fnameEng,job.job_lnameEng,job.job_tel,job.job_status,job.job_date ,job.job_time,job.job_result,job.job_detail,job.job_ansname,job.job_success,job.job_remark,dep.dep_name,type.type_name,status.status_id,status.status_name,status.status_pic
from job
inner join dep on dep.dep_id=job.job_dep_id
inner join type on job.job_type_id=type.type_id
inner join status on status.status_id=job.job_status
where job.job_id='$idedit'";
$result=mysql_db_query($dbname,$sql);
$rs=mysql_fetch_array($result);
$job_id = $rs[job_id];
$job_date=$rs[job_date];
$job_time=$rs[job_time];
$job_fnameth=$rs[job_fnameth];
$job_lnameth=$rs[job_lnameth];
$job_fnameEng=$rs[job_fnameEng];
$job_lnameEng=$rs[job_lnameEng];
$per_id=$rs[per_id];
$dep_name=$rs[dep_name];
$job_tel=$rs[job_tel];
$type_name=$rs[type_name];
$job_detail=$rs[job_detail];
$status_name=$rs[status_name];
$status_pic=$rs[status_pic];
$job_ansname=$rs[job_ansname];
$job_result=$rs[job_result];
$job_success=$rs[job_success];
$job_remark=$rs[job_remark];
$job_status=$_POST[job_status];
?>
<!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=utf-8" />
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<title>ระบบขอใช้บริการ IT SUPPORT ONLINE THANES DEVELOPMENT</title>
<?
$th=mktime(gmdate("H")+7,gmdate("i"),gmdate("m"),gmdate("d"),gmdate("Y"));
$format="H:i ";
$str=date($format,$th);
?>
<?
$d = date('d');
$m = date("m");
$y = (date("Y")+543);
?>
</head>
<body>
<div align="center"><br>
<form action="view1.php" method="post" enctype="multipart/form-data" name="frmAdd" onSubmit="JavaScript:return fncSubmit();">
<table width="90%" border="0" cellspacing="5" cellpadding="0">
<tr bgcolor="#88D5E7">
<td height="30" colspan="5"><div align="center" class="unnamed1">
TEST</div></td>
</tr>
<tr class="unnamed1">
<td width="20%"><div align="right"><strong>วันที่ เวลา : </strong></div></td>
<td width="28%">
<div align="left"><font size = "2"><?=$job_date?>[<?=$job_time?>]</font></div></td>
<td width="4%"> </td>
<td width="29%"><div align="right"><strong>ลำดับ :</strong></div></td>
<td width="19%"><?=$job_id?></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ผู้แจ้ง(ไทย) : </strong></div></td>
<td>
<div align="left"><font size = "2"><?=$job_fnameth?> <?=$job_lnameth?></font></div></td>
<td> </td>
<td><div align="right"><strong>เบอร์ติดต่อภายใน :</strong></div></td>
<td>
<div align="left"><font size = "2"><?=$job_tel?></font></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ผู้แจ้ง(อังกฤษ) : </strong></div></td>
<td>
<div align="left"><font size = "2"><?=$job_fnameEng?> <?=$job_lnameEng?></font></div></td>
<td> </td>
<td><div align="right"><strong>แผนก :</strong></div></td>
<td>
<div align="left"><font size = "2"><?=$dep_name?></font></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>รหัสพนักงาน : </strong></div></td>
<td><div align="left"><font size = "2"><?=$per_id?></font></div></td>
<td> </td>
<td><div align="right"></div></td>
<td><div align="left"></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ความต้องการ : </strong></div></td>
<td colspan="4">
<div align="left"><font size = "2"><?=$type_name?></font></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>รายละเอียด : </strong></div></td>
<td><div align="left"><font size = "2"><?=$job_detail?></font></div></td>
<td> </td>
<td><div align="right"><strong>ผู้รับงาน : </strong></div></td>
<td><div align="left"></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>สถานะงาน : </strong></div></td>
<td>
<div align="left"> <img src="myfile/<?=$status_pic?>"/> <font size = "2"><?=$status_name?></font></div></td>
<td> </td>
<td><div align="right"></div></td>
<td>
<div align="left"></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>ระยะเวลาซ่อม : </strong></div></td>
<td colspan="4">
<div align="left"><font size = "2"><?=$job_success?></font></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"><strong>สรุปผลการซ่อม : </strong></div></td>
<td colspan="4">
<div align="left"><font size = "2"><?=$job_result?></font></div></td>
</tr>
<tr class="unnamed1">
<td colspan="5"><div align="right"></div>
<div align="center"><hr></div></td>
</tr>
<tr class="unnamed1">
<td width="20%"><div align="right">วันที่ : </div></td>
<td width="28%">
<div align="left"><input name="dateedit" type="text" id="dateedit" size="11" maxlength="11" value="<? echo date("$y/$m/$d"); ?>" readonly />
เวลา :
<input name="timeedit" type="text" id="timeedit" size="11" maxlength="11" value="<? echo date("$str ");?>" readonly/></div></td>
<td width="4%"><div align="right"></div></td>
<td width="29%" align="left"><div align="right"></div></td>
<td width="19%"> </td>
</tr>
<tr class="unnamed1">
<td><div align="right">สถานะของงาน : </div></td>
<td>
<div align="left">
<span class="unnamed2">
<SELECT NAME="job_status">
<OPTION VALUE="0">- กรุณาเลือกสถานะงาน -</OPTION>
<?
include "connect.php";
$sql="select * from status";
$result=mysql_db_query($dbname,$sql);
while($rs=mysql_fetch_array($result)) {
$status_id=$rs[status_id];
$status_name=$rs[status_name];
echo "<OPTION VALUE='$status_id'>$status_name</OPTION>";
}
?>
</SELECT>
</span> </div></td>
<td> </td>
<td><div align="right">ผู้รับงาน : </div></td>
<td><div align="left">
<span class="unnamed2">
<input name="job_ansname" type="text" id="job_ansname" size="11" maxlength="11" value="<?=$objResult["user_name"];?>" readonly/>
</span> </div></td>
</tr>
<tr class="unnamed1">
<td><div align="right">ระยะเวลาซ่อม : </div></td>
<td><div align="left">
<input name="job_success" type="text" id="job_success" size="15" value="<?=$job_success?>"/>
</div></td>
<td> </td>
<td><div align="right"> </div></td>
<td><div align="left"></div></td>
</tr>
<tr class="unnamed1">
<td><div align="right">สรุปผลการซ่อม : </div></td>
<td colspan="4"><div align="left">
<textarea name="job_result" cols="60" rows="5" id="job_result"><?=$job_result?></textarea>
</div></td>
</tr>
<tr class="unnamed1">
<td><div align="right">หมายเหตุ :</div></td>
<td colspan="4"><div align="left">
<textarea name="job_remark" cols="60" rows="5" id="job_remark"><?=$job_remark?></textarea>
</div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"></div></td>
<td colspan="4"><div align="left">
<? echo"<input type='submit' name='submit' value='Submit'><INPUT NAME='id_edit' TYPE='hidden' VALUE='$id_edit'>"; ?><input type="reset" name="Reset" value="Clear">
</div></td>
</tr>
<tr class="unnamed1">
<td><div align="right"></div></td>
<td> </td>
<td> </td>
<td><div align="right"></div></td>
<td> </td>
</tr>
</table>
</form>
<br>
</div>
</body>
</html>
ขอบคุณครับ
Tag : PHP, MySQL, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2013-07-25 14:07:23 |
By :
ruud |
View :
697 |
Reply :
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo ตัวแปร $sql แล้วได้ผลยังไงครับ เอามาแปะให้ดูหน่อยครับ
|
|
|
|
|
Date :
2013-07-25 14:54:47 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update job set job_status='3',job_result='ujhhj',job_ansname='ddd',job_success='15นาที',job_remark='test' where job_id='1'
|
|
|
|
|
Date :
2013-07-25 15:05:32 |
By :
ruud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
$result=mysql_db_query($dbname,$sql);
ตัวแปร $dbname ไม่มีนิครับคุณใช้ $objDB ในการ select_db $objDB = mysql_select_db("request"); นิครับ เปลี่ยนเป็น
Code (PHP)
$result=mysql_db_query($objDB,$sql);
แต่แนะนำให้ใช้
Code (PHP)
$result=mysql_query($sql);
แค่นี้พอครับ mysql_db_query มันโบราณไปครับ
|
|
|
|
|
Date :
2013-07-25 15:16:07 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ได้อ่ะครับ มันขึ้นเหมือนเดิมเลย
|
|
|
|
|
Date :
2013-07-25 15:29:09 |
By :
ruud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำได้แล้วครับ ขอบคุณมากครับ
|
|
|
|
|
Date :
2013-07-25 15:43:39 |
By :
ruud |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2013-07-25 15:51:09 |
By :
Manussawin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|