|
|
|
สอบถามปัญหาเกี่ยว กับ การ insert หน่อยครับ คือ พอ ดี เวลา ผม insert |
|
|
|
|
|
|
|
datetime ใน Mysql จะมี format เป็น y/m/d h:m:s
$strDate = 04/28/2011
list($m,$d,$y) = split($strDate);
$strDate = "$y-$m-$d".$strTime;
|
|
|
|
|
Date :
2011-04-28 15:02:19 |
By :
naskw |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ยังไม่ได้อ่ะ ครับ งง เลย ที่ นี้ จะลองดู โค๊ดไม ล่ะครับ
|
|
|
|
|
Date :
2011-04-28 15:15:02 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ขุดๆๆๆๆๆๆๆๆๆๆๆๆมุดๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆๆ
|
|
|
|
|
Date :
2011-04-28 16:02:57 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
หน้า insertandedit
Code (PHP)
<?php session_start();
if(!session_is_registered('loginname')){
header("location:formlogin.php");
}
/* echo $_SESSION['loginname'];
echo $_SESSION['pw']; */
$name = $_SESSION['loginname'];
$pass = $_SESSION['pw'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!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>
<style type="text/css">
body { font-size: 14px;}
legend {font-size:12px; font-weight:bold;color:#00F;}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Themeroller-Ready jQuery UI Range Picker</title>
<script type="text/javascript" src="calendar/js/jquery-1.3.1.min.js"></script>
<script type="text/javascript" src="calendar/js/jquery-ui-1.7.1.custom.min.js"></script>
<script type="text/javascript" src="calendar/js/daterangepicker.jQuery.js"></script>
<link rel="stylesheet" href="calendar/css/ui.daterangepicker.css" type="text/css" />
<link rel="stylesheet" href="calendar/css/redmond/jquery-ui-1.7.1.custom.css" type="text/css" title="ui-theme" />
<script type="text/javascript">
$(function(){
$('#n_date').daterangepicker({arrows:true});
$('#s_date_timein').daterangepicker({arrows:true});
$('#s_date_time_out').daterangepicker({arrows:true}) ;
});
</script>
</style>
</head><?
include "./include/connect1.php";
?>
<body>
<form id="form1" name="form1" method="post" action="insertandedit1.php">
<p> <strong>Employee Detail</strong></p>
<table width="782" height="44" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr class="font22">
<td width="778" valign="top"><table width="1028" border="1" align="center" cellpadding="0" cellspacing="1">
<tr class="header24">
<td colspan="11" bgcolor="#F0F0F0"><div align="center" class="header">
<h3>Employee Detail</h3>
</div></td>
</tr>
<tr bordercolor="#FFFFFF" bgcolor="#CCCCCC" class="font22">
<td width="85" align="center" class="font14-5"><div align="center">User_id</div></td>
<td width="171" align="center" class="font14-5">name</td>
<td width="208" align="center" class="font14-5"><div align="center">lname</div></td>
<td width="301" align="center" class="font14-5"><div align="center">position</div></td>
<td width="245" align="center" class="font14-5"><div align="center">Grade and step</div></td>
</tr>
<?
/* $dte1 = $_REQUEST['dte1']; */
// $dte2 = $_REQUEST['dte2'];
/* $start = $dte1; <?php echo $_SESSION['userid']; ?>" */
// $end = $dte2;
$sql_seleect = "select distinct u.user_id,fname,lname,position,gradeandstep
from user_table u,time_sheet_table t
where u.user_id = t.user_id and username = '$name' and password = '$pass' "; /* ตรงนี้เขียนอย่างงี้ได้ไหม ครับ */
$result_select = mysql_query($sql_seleect) or die(mysql_error());
while($read_data = mysql_fetch_array($result_select)){
?>
<tr class="font18">
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['user_id'] ;?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['fname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['lname']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['position']; ?></div></td>
<td align="left" valign="top" class="font14-0"><div align="center"><? echo $read_data['gradeandstep']; ?></div></td>
</tr>
<? $user1 = $read_data['user_id'];
/* echo $user1 ; */
?>
<? }?>
</table></td>
</tr>
</table>
<p> </p>
<hr />
<p><storng>
<center>
<p>Day :
<input type="text" name="day" id="day" />
</p>
<p>Monday- Sunday</p>
</center>
<center><fieldset>
<legend>Nomal Time:</legend>
<p>Date:
<input type="text" name="n_date" id="n_date" />
<input type="hidden" name="user_id" value="<? echo $user1 ;?>" />
</p>
<p>YYYY-MM-DD<br />
<br />
Time in:
<input type="text" name="n_timein" id="n_timein" />
</p>
<p>HH:MM:SS</p>
<p>
Time out :
<input type="text" name="n_timeout" id="n_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center>
</p><hr />
<p><center><fieldset>
<legend>Shift Time</legend>
<p>Date:
<input type="text" name="s_date_timein" id="s_date_timein" />
</p>
<p>YYYY-MM-DD <br />
Time in:
<input type="text" name="s_timein" id="s_timein" />
</p>
<p>HH:MM:SS</p>
<p>Date:
<input type="text" name="s_date_time_out" id="s_date_time_out" />
</p>
<p>YYYY-MM-DD</p>
<p>
Time out :
<input type="text" name="s_timeout" id="s_timeout" />
</p>
<p>HH:MM:SS</p>
</fieldset></center></p><hr /><center><fieldset>
<legend><font size="4">Key Accomplishments</font></legend>
<p>
<textarea name="detail" id="detail" cols="45" rows="5"></textarea>
</p>
</fieldset></center></p>
<p>
<input type="submit" name="button" id="Insert" value="Insert" />
<a href="formlogin.php">กลับหน้า Login</a></p>
</form>
</body>
</html>
หน้า insertandedit 1
Code (PHP)
<?
$host = "127.0.0.1";
$user = "root";
$password = "12345";
$dbname = "rimes1";
mysql_connect($host,$user,$password) or die("ติดต่อ Host ไม่ได้");
mysql_select_db($dbname) or die ("ติดต่อฐานข้อมูลไม่ได้");
/* $test = "Nong sanokdee";
$mystring="ผมชื่อนายอิน สุขสันต์ บ้านอยู่โนนมะโดก ใครๆก็รู้จัก เพราะผมมันหล่อ";
$thisarr=explode(' ',$mystring);
$thisarr[0]="ผมชื่อนายอิน";
$thisarr[1]="สุขสันต์";
$thisarr[2]="บ้านอยู่โนนมะโดก";
$thisarr[3]="ใครๆก็รู้จัก";
$thisarr[4]="เพราะผมมันหล่อ";
echo $thisarr['0'] ;
echo $thisarr['1'] ;
('$day','". $sum_n. "','". $sum_n_out. "','$detail','". $sum_s_in."','". $sum_s_out. "')";
*/
$day = $_POST['day'];
$userid = $_POST['user_id'];
$n_date =$_POST['n_date'];
$n_timein = $_POST['n_timein'];
$n_timeout =$_POST['n_timeout'];
$s_date_timein =$_POST['s_date_timein'];
$s_timein = $_POST['s_timein'];
$s_date_time_out =$_POST['s_date_time_out'];
$s_timeout = $_POST['s_timeout'];
$detail = $_POST['detail'];
$strDate = $n_date ;
echo $srtDate ;
list($m,$d,$y) = split($strDate);
$strDate = "$y-$m-$d".$strTime;
// เป็นการ ต่อ สติงวันที่เพื่อนำไปใช้งานใส่กันวันที่ (day,detail,n_timein,n_timeout,s_timein,s_timeout) values ('$day','$detail','$sum_n','$sum_n_out','$sum_s_in','$sum_s_out')
$sum_n = $_POST['n_date'] . ' '. $_POST['n_timein'];
echo $sum_n ;
$sum_n_out = $_POST['n_date'] . ' ' . $_POST['n_timeout'];
$sum_s_in = $_POST['s_date_timein'] . ' ' .$_POST['s_timein'];
$sum_s_out = $_POST['s_date_time_out'] . ' ' .$_POST['s_timeout'];
$sql = "insert into time_sheet_table (day,detail,n_timein,n_timeout,s_timein,s_timeout,user_id) values ('$day','$detail','$sum_n','$sum_n_out','$sum_s_in','$sum_s_out','$userid') " ;
mysql_query($sql) or die;
/* echo $n_timein ; */
/* $sql2 = "insert into time_sheet_table (n_timeout)values('". $sum_n_out. "')";
mysql_query($sql2);
*/
?>
<a href="insertandedit.php">00000</a>
ดู ให้ที ครับ ่วา ควร จะ แก้ไขตรงไหนดี
|
|
|
|
|
Date :
2011-04-28 16:04:45 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ดันๆๆๆๆๆ
|
|
|
|
|
Date :
2011-04-28 16:50:11 |
By :
macro |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|