|
|
|
คือผม ทำหน้าedit อยู่ อ่ะครับ แต่มันเกิดปัญหานิหน่อย ช่วย ดู ให้ หน่อย ครับ |
|
|
|
|
|
|
|
echo "<meta http-equiv='refresh' content='0;URL=หน้าที่จะไป.php?username=$username'>
เอา code มาดูหน่อยครับ
|
|
|
|
|
Date :
2011-04-22 11:14:57 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้า 1 edit
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
echo $_SESSION['loginname'];echo nl2br ("");
echo $_SESSION['pw'];
$name = $_SESSION['loginname'];
$pass = $_SESSION['pw'];
?>
<?
$host="localhost";
$user="root";
$pw="12345";
$db="rimes1";
mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_query("set NAMES tis620");
$result = mysql_select_db($db) or die(mysql_error());
?>
<!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>Untitled Document</title>
</head>
<body>
<center>
<p>
</p>
<table width="1342" height="216" border="1">
<tr>
<td height="96" colspan="13">Edit Table</td>
</tr>
<tr>
<td width="43" align="center" valign="middle">NO.</td>
<td width="21" align="center" valign="middle">User_id</td>
<td width="21" align="center" valign="middle">DAY</td>
<td width="117" height="47" align="center" valign="middle">Nomal date</td>
<td width="133" align="center" valign="middle">Nomal time in</td>
<td width="141" align="center" valign="middle">Nomal time Out</td>
<td width="125" align="center" valign="middle">Shift date </td>
<td width="128" align="center" valign="middle">shift time in </td>
<td width="130" align="center" valign="middle">shift date time out</td>
<td width="111" align="center" valign="middle">shift time out</td>
<td width="139" align="center" valign="middle">Detail</td>
<td width="139" align="center" valign="middle">Edit</td>
<td width="20" align="center" valign="middle">Delete</td>
</tr>
<?
$sql = "select *,id,day,time_sheet_table.user_id,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout,detail
from time_sheet_table ,user_table
where user_table.user_id = time_sheet_table.user_id
and username = '$name' and password = '$pass'
";
$nongA = mysql_query($sql);
while ($test =mysql_fetch_array($nongA)){
?>
<tr>
<td width="43" align="center" valign="middle"><? echo $test['1']?></td>
<td width="21" align="center" valign="middle"><? echo $test['user_id'];?></td>
<td width="21" align="center" valign="middle"><? echo $test['day']; ?></td>
<td><? echo $test['n_date'];?></td>
<td><? echo $test['ntimein'];?></td>
<td><? echo $test['ntimeout'];?></td>
<td><? echo $test['s_date_timein'];?></td>
<td width="128"><? echo $test['stimein'];?></td>
<td width="130" align="center" valign="middle"><? echo $test['s_date_out'];?></td>
<td width="111" align="center" valign="middle"><? echo $test['stimeout'];?></td>
<td width="139" align="center" valign="middle"><? echo $test['detail'];?></td>
<td width="139" align="center" valign="middle"><a href="edit1.php?id=<? echo $test['id']?>">Edit</a></td>
<td width="20" align="center"><a href="delete.php?id=<? echo $test['id']?>">Delete</a></td>
</tr>
<? } ?>
</table>
</center>
</body>
</html>
หน้าที่2 edit1
Code (PHP)
<?
session_start();
include "./include/connect1.php";
session_register("sess_id");
if(!session_is_registered('loginname')){
header("location:formlogin.php");
header("location:edit.php");
}
echo $_SESSION['loginname'];echo nl2br ("");
echo $_SESSION['pw'];
$name = $_SESSION['loginname'];
$pass = $_SESSION['pw'];
?>
<style type="text/css">
<!--
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style1{
font-size:15px;
font-weight:bold;
}
.style2 {
font-size: 16px;
font-weight:bold;
color: #4A2616;
}
.style26 {font-family: "Angsana New", Batang, "Bodoni MT", Calibri; font-size: 20px; font-weight: bold; }
.style28 {font-family: "Angsana New", Batang, "Bodoni MT", Calibri; font-size: 20px; }
-->
</style>
<table align="right" width="80%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td align="center"><form action="update_database.php" method="post"><table width="100%" border="0" cellspacing="0">
<tr>
<td background="image/bgu.jpg" height="100"></td>
</tr>
<tr>
<td background="image/bgm.jpg" align="center"><table width="80%" border="0" align="center">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?
$id=$_GET['id'];
$name1 = $name ;
$pass1 = $pass ;
$sql="select *,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout
from time_sheet_table,user_table
where id = '$id' ";
$a=mysql_query($sql);
$read= mysql_fetch_array ($a);
?>
<tr>
<td> </td>
<td>รหัส :</td>
<td><span class="style26"><? echo $read['id']; ?>
<input type="hidden" name="id" value="<?=$read['id'] ?>"/>
</span></td>
<td> </td>
</tr>
<tr>
<td width="20%"> </td>
<td width="20%" class="style2">Day : </td>
<td width="40%"><input type="text" name="day" value="<?=$read['day']?>"/>
<? echo $name ;?></td>
<td width="20%"> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Nomal date : </td>
<td><input type="text" name="n_date" value="<?=$read['n_date']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Nomal Time in :</td>
<td><input type="text" name="ntimein" value="<?=$read['ntimein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2"><p>Nomal Time out :</p></td>
<td><input type="text" name="ntimeout" value="<?=$read['ntimeout']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Shift date in :</td>
<td><input type="text" name="s_date_timein" value="<?=$read['s_date_timein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td valign="top" class="style2"> Shift timein :</td>
<td><input type="text" name="stimein" value="<?=$read['stimein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Shift date out :</td>
<td><input type="text" name="s_date_out" value="<?=$read['s_date_out']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Shift Time out :</td>
<td><input type="text" name="stimeout" value="<?=$read['stimeout']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Detail :</td>
<td><textarea name="detail" cols="45" id="detail"><?=$read['detail']?>
</textarea></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="ok" value="แก้ไข" style="background-color:#7B533A; color:#FFFFFF"/> <span class="style28">
<?
$day=$_REQUEST['day'];
$n_date=$_REQUEST['n_date'];
$ntimein=$_REQUEST['ntimein'];
$ntimeout=$_REQUEST['ntimeout'];
$s_date_timein=$_REQUEST['s_date_timein'];
$stimein=$_REQUEST['stimein'];
$s_date_out=$_REQUEST['s_date_out'];
$stimeout=$_REQUEST['stimeout'];
$detail=$_REQUEST['detail'];
/* $sum_n2 = $_POST['n_date'] . ' ' . $_POST['ntimein'];
*/
?>
</span></td>
</tr>
</table>
<p>
<?
echo $id ;
echo nl2br($detail);
echo $day;
?>
</p></td>
</tr>
<tr>
</tr>
</table>
</form></td></tr>
</table>
หน้า update_database
Code (PHP)
<?php
$host="localhost";
$user="root";
$pw="12345";
$db="rimes1";
mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_query("set NAMES tis620");
$result = mysql_select_db($db) or die(mysql_error());
$id = $_POST['id'];
$day = $_POST['day'];
$detail = $_POST['detail'];
$sum_n = $_POST['n_date'] . ' '. $_POST['ntimein'];
$sum_n_time_out = $_POST['n_date'] . ' ' . $_POST['ntimeout'];
$sum_s_date_time_in = $_POST['s_date_timein'] . ' ' . $_POST['stimein'];
$sum_s_date_time_out = $_POST['s_date_out'] . ' ' . $_POST['stimeout'];
echo $id;
echo $day;
echo $detail ;
echo $sum_n ;
echo $sum_n_time_out ;
echo $sum_s_date_time_in ;
echo $sum_s_date_time_out ;
$sql = "UPDATE time_sheet_table SET detail = '$detail',
day = '$day',
n_timein = '$sum_n',
n_timeout = '$sum_n_time_out',
s_timein = '$sum_s_date_time_in' ,
s_timeout = '$sum_s_date_time_out'
where id ='$id' ";
$show = mysql_query($sql) ;
$objQuery = $show ;
if($objQuery)
{
/* echo "<script>alert('....succeed.....');window.location='edit.php';</script>"; */
}
else
{
/* echo " no commplet "; */
}
?>
'ช่วยหน่อน น่ะครับ + คำอธิบายด้วยน่ะครับ จะได้เข้าใจ
|
|
|
|
|
Date :
2011-04-22 11:27:31 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขุดๆๆ
|
|
|
|
|
Date :
2011-04-22 12:04:14 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำตามด้านบนหรือยังครับ
|
|
|
|
|
Date :
2011-04-22 12:34:53 |
By :
Dragons_first |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ทำแล้วครับ แต่ ยังไม่ได้ เลย ครับ
|
|
|
|
|
Date :
2011-04-22 12:42:39 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ไม่ไหว แล้ว ครับ แก้ ตั้ง แต่ เช้ายังไม่ได้เล่นครับ พี่น้อง
|
|
|
|
|
Date :
2011-04-22 13:35:58 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ข้อมูลที่แก้ไขมานสามารถแก้ไขได้หรือป่าวค่ะ
|
|
|
|
|
Date :
2011-04-22 13:45:32 |
By :
nongking1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ปัญหาของคุณคือ มันไม่ยอมแก้ไขข้อมูลให้หรือว่ายังไงครับ
|
|
|
|
|
Date :
2011-04-22 13:47:49 |
By :
naskw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ฟอร์มแสดงข้อมูล
<td><? echo $test['n_date'];?></td>
<td><? echo $test['ntimein'];?></td>
<td><? echo $test['ntimeout'];?></td>
<td><? echo $test['s_date_timein'];?></td>
<td width="128"><? echo $test['stimein'];?></td>
<td width="130" align="center" valign="middle"><? echo $test['s_date_out'];?></td>
<td width="111" align="center" valign="middle"><? echo $test['stimeout'];?></td>
<td width="139" align="center" valign="middle"><? echo $test['detail'];?></td>
<td width="139" align="center" valign="middle"><a href="edit1.php?id=<? echo $test['id']?>">Edit</a></td>ผิดที่บรรทัดนี้แหละจ้า
<td width="20" align="center"><a href="delete.php?id=<? echo $test['id']?>">Delete</a></td> ผิดที่บรรทัดนี้แหละจ้า
ลองเอาตัวนี้ไปใช้ดูนะค่ะ
<td width="139" align="center" valign="middle"><a href="edit1.php?id=<? echo $test['id'];?>">Edit</a></td>
<td width="20" align="center"><a href="delete.php?id=<? echo $test['id'];?>">Delete</a></td>
ได้ผลงัยบอกด้วยนะจ้า
สู้ๆๆๆ
|
|
|
|
|
Date :
2011-04-22 13:51:49 |
By :
nongking1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันแก้ไขให้ครับ แต่ ผม ต้องการ จะ ทำ ให้ มัน แสดง ข้อมูล ที่แก้ไข แล้ว ออก มา โชว์ อ่ะ ครับ
|
|
|
|
|
Date :
2011-04-22 13:53:09 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณก็คิวรีข้อมูล ไอดี ที่คุณแก้ไขขึ้นมาแสดงใหม่ หรือไม่ก็ echo ค่าจากตัวแปรที่ส่งมา update ออกมาก็ได้นี่
ใส่ตรงคำสั่งข้างล่างนี้ก็น่าจะได้นะ
Code (PHP)
if($objQuery)
{
/* echo ตรงนี้ก็น่าจะได้นะ ผมว่า หรือว่าติดตรงไหน*/
}
else
{
/* echo " no commplet "; */
}
|
|
|
|
|
Date :
2011-04-22 13:57:26 |
By :
naskw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้า update_database
<?php
$host="localhost";
$user="root";
$pw="12345";
$db="rimes1";
mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_query("set NAMES tis620");
$result = mysql_select_db($db) or die(mysql_error());
$id = $_POST['id'];
$day = $_POST['day'];
$detail = $_POST['detail'];
$sum_n = $_POST['n_date'] . ' '. $_POST['ntimein'];
$sum_n_time_out = $_POST['n_date'] . ' ' . $_POST['ntimeout'];
$sum_s_date_time_in = $_POST['s_date_timein'] . ' ' . $_POST['stimein'];
$sum_s_date_time_out = $_POST['s_date_out'] . ' ' . $_POST['stimeout'];
echo $id;
echo $day;
echo $detail ;
echo $sum_n ;
echo $sum_n_time_out ;
echo $sum_s_date_time_in ;
echo $sum_s_date_time_out ;
$sql = "UPDATE time_sheet_table SET detail = '$detail',
day = '$day',
n_timein = '$sum_n',
n_timeout = '$sum_n_time_out',
s_timein = '$sum_s_date_time_in' ,
s_timeout = '$sum_s_date_time_out'
where id ='$id' ";
$show = mysql_query($sql) ;
$objQuery = $show ;
if($objQuery)
{
echo "<center>
<tr>
<center>
<font size=\"5\" color=\"#000080\">แก้ไขสำเร็จ</font><br><br>
<font size=\"4\"><a href=\"edits.php\">ตกลง</a></font>
</center>
</td>
</tr>
</center>";
}
else {
echo "<center>
<tr>
<center>
<font size=\"5\" color=\"#000080\">ไม่สามารถแก้ไขได้ !!</font><br><br>
<font size=\"4\"><a href=\"edit.php\">ตกลง</a></font>
</center>
</td>
</tr>
</center>";
}
?>
ลองดูนะจ้าว่าใช่อย่างนี้หรือเปบ่านะจ้า
สู้ๆๆได้ผลงัยบอกด้วยนะจ้า
|
|
|
|
|
Date :
2011-04-22 14:03:12 |
By :
nongking1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ตกลงว่าแก้แล้วจะให้มันแสดงข้อมูลที่เราแก้
หรือว่าแก้แล้ว ให้กลับไปที่หน้าแรก
|
|
|
|
|
Date :
2011-04-22 14:08:08 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
คุณมั่นใจไหมว่าค่าได้ถูก update แล้วจริงๆ ดูในฐานข้อมูลแล้วหรือยังครับ ลอง echo คำสั่ง update ได้ไหมครับว่าตรงกับข้อมูลที่ต้องการหรือเปล่า
|
|
|
|
|
Date :
2011-04-22 14:10:48 |
By :
chubichane |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
สรุปให้
edit.php
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
echo $_SESSION['loginname'];echo nl2br ("");
echo $_SESSION['pw'];
//เช็คว่า ได้มาจากหน้า update_database.php หรือไม่
if (!$_GET['check'] == "update") { //ถ้าไม่มา
$name = $_SESSION['loginname'];
$pass = $_SESSION['pw'];
}
else
{//ถ้ามา
$name = $_GET['username'];
$pass = $_GET['password'];
}
?>
<?
$host="localhost";
$user="root";
$pw="12345";
$db="rimes1";
mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_query("set NAMES tis620");
$result = mysql_select_db($db) or die(mysql_error());
?>
<!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>Untitled Document</title>
</head>
<body>
<center>
<p>
</p>
<table width="1342" height="216" border="1">
<tr>
<td height="96" colspan="13">Edit Table</td>
</tr>
<tr>
<td width="43" align="center" valign="middle">NO.</td>
<td width="21" align="center" valign="middle">User_id</td>
<td width="21" align="center" valign="middle">DAY</td>
<td width="117" height="47" align="center" valign="middle">Nomal date</td>
<td width="133" align="center" valign="middle">Nomal time in</td>
<td width="141" align="center" valign="middle">Nomal time Out</td>
<td width="125" align="center" valign="middle">Shift date </td>
<td width="128" align="center" valign="middle">shift time in </td>
<td width="130" align="center" valign="middle">shift date time out</td>
<td width="111" align="center" valign="middle">shift time out</td>
<td width="139" align="center" valign="middle">Detail</td>
<td width="139" align="center" valign="middle">Edit</td>
<td width="20" align="center" valign="middle">Delete</td>
</tr>
<?
$sql = "select *,id,day,time_sheet_table.user_id,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout,detail
from time_sheet_table ,user_table
where user_table.user_id = time_sheet_table.user_id
and username = '$name' and password = '$pass'
";
$nongA = mysql_query($sql);
while ($test =mysql_fetch_array($nongA)){
?>
<tr>
<td width="43" align="center" valign="middle"><? echo $test['1']?></td>
<td width="21" align="center" valign="middle"><? echo $test['user_id'];?></td>
<td width="21" align="center" valign="middle"><? echo $test['day']; ?></td>
<td><? echo $test['n_date'];?></td>
<td><? echo $test['ntimein'];?></td>
<td><? echo $test['ntimeout'];?></td>
<td><? echo $test['s_date_timein'];?></td>
<td width="128"><? echo $test['stimein'];?></td>
<td width="130" align="center" valign="middle"><? echo $test['s_date_out'];?></td>
<td width="111" align="center" valign="middle"><? echo $test['stimeout'];?></td>
<td width="139" align="center" valign="middle"><? echo $test['detail'];?></td>
<td width="139" align="center" valign="middle"><a href="edit1.php?id=<? echo $test['id']?>">Edit</a></td>
<td width="20" align="center"><a href="delete.php?id=<? echo $test['id']?>">Delete</a></td>
</tr>
<? } ?>
</table>
</center>
</body>
</html>
/**********************************
edit1.php
Code (PHP)
<?
session_start();
include "./include/connect1.php";
session_register("sess_id");
if(!session_is_registered('loginname')){
header("location:formlogin.php");
header("location:edit.php");
}
echo $_SESSION['loginname'];echo nl2br ("");
echo $_SESSION['pw'];
$name = $_SESSION['loginname'];
$pass = $_SESSION['pw'];
?>
<style type="text/css">
<!--
a:link {
color: #FFFFFF;
text-decoration: none;
}
a:visited {
text-decoration: none;
}
a:hover {
text-decoration: none;
}
a:active {
text-decoration: none;
}
.style1{
font-size:15px;
font-weight:bold;
}
.style2 {
font-size: 16px;
font-weight:bold;
color: #4A2616;
}
.style26 {font-family: "Angsana New", Batang, "Bodoni MT", Calibri; font-size: 20px; font-weight: bold; }
.style28 {font-family: "Angsana New", Batang, "Bodoni MT", Calibri; font-size: 20px; }
-->
</style>
<table align="right" width="80%" border="0" cellpadding="4" cellspacing="0">
<tr>
<td align="center"><form action="update_database.php" method="post"><table width="100%" border="0" cellspacing="0">
<tr>
<td background="image/bgu.jpg" height="100"></td>
</tr>
<tr>
<td background="image/bgm.jpg" align="center"><table width="80%" border="0" align="center">
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?
$id=$_GET['id'];
$name1 = $name ;
$pass1 = $pass ;
$sql="select *,
DATE_FORMAT(n_timein,'%H:%i') as ntimein,
DATE_FORMAT(n_timeout,'%H:%i')as ntimeout,
DATE_FORMAT(n_timein,'%Y-%m-%d') As n_date,
DATE_FORMAT(s_timein,'%Y-%m-%d') As s_date_timein,
DATE_FORMAT(s_timeout,'%Y-%m-%d') As s_date_out,
DATE_FORMAT(s_timein,'%H:%i') as stimein,
DATE_FORMAT(s_timeout,'%H:%i') as stimeout
from time_sheet_table,user_table
where id = '$id' ";
$a=mysql_query($sql);
$read= mysql_fetch_array ($a);
?>
<tr>
<td> </td>
<td>รหัส :</td>
<td><span class="style26"><? echo $read['id']; ?>
<input type="hidden" name="id" value="<?=$read['id'] ?>"/>
</span></td>
<td> </td>
</tr>
<input type="hidden" name="hidden_username" value="<?=$name1;?>"/><!-- ซ่อนฟิลด์แล้วส่งตัวแปร username ไป -->
<input type="hidden" name="hidden_password" value="<?=$pass1;?>"/><!-- ซ่อนฟิลด์แล้วส่งตัวแปร password ไป -->
<tr>
<td width="20%"> </td>
<td width="20%" class="style2">Day : </td>
<td width="40%"><input type="text" name="day" value="<?=$read['day']?>"/>
<? echo $name ;?></td>
<td width="20%"> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Nomal date : </td>
<td><input type="text" name="n_date" value="<?=$read['n_date']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Nomal Time in :</td>
<td><input type="text" name="ntimein" value="<?=$read['ntimein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2"><p>Nomal Time out :</p></td>
<td><input type="text" name="ntimeout" value="<?=$read['ntimeout']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Shift date in :</td>
<td><input type="text" name="s_date_timein" value="<?=$read['s_date_timein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td valign="top" class="style2"> Shift timein :</td>
<td><input type="text" name="stimein" value="<?=$read['stimein']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Shift date out :</td>
<td><input type="text" name="s_date_out" value="<?=$read['s_date_out']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>Shift Time out :</td>
<td><input type="text" name="stimeout" value="<?=$read['stimeout']?>"/></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td class="style2">Detail :</td>
<td><textarea name="detail" cols="45" id="detail"><?=$read['detail']?>
</textarea></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><input type="submit" name="ok" value="แก้ไข" style="background-color:#7B533A; color:#FFFFFF"/> <span class="style28">
<?
$day=$_REQUEST['day'];
$n_date=$_REQUEST['n_date'];
$ntimein=$_REQUEST['ntimein'];
$ntimeout=$_REQUEST['ntimeout'];
$s_date_timein=$_REQUEST['s_date_timein'];
$stimein=$_REQUEST['stimein'];
$s_date_out=$_REQUEST['s_date_out'];
$stimeout=$_REQUEST['stimeout'];
$detail=$_REQUEST['detail'];
/* $sum_n2 = $_POST['n_date'] . ' ' . $_POST['ntimein'];
*/
?>
</span></td>
</tr>
</table>
<p>
<?
echo $id ;
echo nl2br($detail);
echo $day;
?>
</p></td>
</tr>
<tr>
</tr>
</table>
</form></td></tr>
</table>
//*****************************
update_database.php
Code (PHP)
<?php
$host="localhost";
$user="root";
$pw="12345";
$db="rimes1";
mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_query("set NAMES tis620");
$result = mysql_select_db($db) or die(mysql_error());
$id = $_POST['id'];
$day = $_POST['day'];
$detail = $_POST['detail'];
$username = $_POST['hidden_username'];//ตัวแปรที่ซ่อนแล้วส่งมา
$password = $_POST['hidden_password'];//ตัวแปรที่ซ่อนแล้วส่งมา
$sum_n = $_POST['n_date'] . ' '. $_POST['ntimein'];
$sum_n_time_out = $_POST['n_date'] . ' ' . $_POST['ntimeout'];
$sum_s_date_time_in = $_POST['s_date_timein'] . ' ' . $_POST['stimein'];
$sum_s_date_time_out = $_POST['s_date_out'] . ' ' . $_POST['stimeout'];
echo $id;
echo $day;
echo $detail ;
echo $sum_n ;
echo $sum_n_time_out ;
echo $sum_s_date_time_in ;
echo $sum_s_date_time_out ;
$sql = "UPDATE time_sheet_table SET detail = '$detail',
day = '$day',
n_timein = '$sum_n',
n_timeout = '$sum_n_time_out',
s_timein = '$sum_s_date_time_in' ,
s_timeout = '$sum_s_date_time_out'
where id ='$id' ";
$show = mysql_query($sql) ;
$objQuery = $show ;
if($objQuery)
{
// redirect ไปหน้า edit.php โดยส่งตัวแปร username , password , check ไปด้วย
echo "<meta http-equiv='refresh' content='0;URL=edit.php?username=$username&password=$password&check=update'>";
}
else
{
/* echo " no commplet "; */
}
?>
|
|
|
|
|
Date :
2011-04-22 14:26:02 |
By :
avsqlz |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|