|
|
|
ขอถามอะไรหน่อยน่ะครับเกี่ยว กับ การใช่ if else เพื่อ ให้เกิด กรอปที่ ดต้ ตอบคำถามอ่ะครับ |
|
|
|
|
|
|
|
Code (PHP)
<?
session_start();
include "./include/connect1.php";
session_register("sess_id");
?>
<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="" 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'];
$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
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="P_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']?>"/></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">
<?
$id =$read['id'];
$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'];
?>
</span></td>
<td><h><?= $test['id'] ?></h></td>
</tr>
</table>
<p>
<?
echo $id ;
echo $day . "\n";
echo $n_date;
echo "\n";
$sql = "UPDATE time_sheet_table SET detail = '$detail'
where id = '$id' ";
mysql_query($sql) ;
//ตรงนี้อ่ะครับ ผมควรจะเขียน if else ยังไงดีครับให้มันบอกว่าถ้าเสร็จ แล้วให้ ขึ้นว่าเสร็จถ้ายังให้ขึ้นว่าไม่เสร็จอ่ะครับ
echo "<script>alert('com....');window.location='edit.php'</script>";
?>
</p></td>
</tr>
<tr>
</tr>
</table></form></td></tr>
</table>
ช่วยแนะนำหน่อย น่ะ ครับ หรือว่า ช่วย เอง โค๊ดตัวอย่างให้ดูที่น่ะครับ ขอคุณร่วงหน้า เลย น่ะ ครับ
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2011-04-11 13:36:47 |
By :
macro |
View :
859 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<html>
<head>
<title>ThaiCreate.Com PHP & MySQL Tutorial</title>
</head>
<body>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("mydatabase");
$strSQL = "UPDATE customer SET ";
$strSQL .="CustomerID = '".$_POST["txtCustomerID"]."' ";
$strSQL .=",Name = '".$_POST["txtName"]."' ";
$strSQL .=",Email = '".$_POST["txtEmail"]."' ";
$strSQL .=",CountryCode = '".$_POST["txtCountryCode"]."' ";
$strSQL .=",Budget = '".$_POST["txtBudget"]."' ";
$strSQL .=",Used = '".$_POST["txtUsed"]."' ";
$strSQL .="WHERE CustomerID = '".$_GET["CusID"]."' ";
$objQuery = mysql_query($strSQL);
if($objQuery)
{
echo "Save Done.";
}
else
{
echo "Error Save [".$strSQL."]";
}
mysql_close($objConnect);
?>
</body>
</html>
ref : https://www.thaicreate.com/php/php-mysql-update-edit-record.html
ลองดูตัวอย่างแล้วเอาไปปรับใช้นะครับ
|
|
|
|
|
Date :
2011-04-11 18:46:27 |
By :
pokultra |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|