|
 |
|
ขอความช่วยเหลือหน่อยครับ จะทำระบบลงเวลาเข้า ออก แต่ได้แค่ลงเข้า เหลือลงออก ต้องทำยังไงเหรอครับ |
|
 |
|
|
 |
 |
|

ได้แค่ลงเข้า เหลือลงออก ต้องทำยังไงเหรอครับ
Code (PHP)
<?php require_once('Connections/myconnet.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO `time` (id, name,date,time_in) VALUES (%s, %s,CURDATE(),CURTIME())",
GetSQLValueString($_POST['id'], "text"),
GetSQLValueString($_POST['name'], "text"));
mysql_select_db($database_myconnet, $myconnet);
$Result1 = mysql_query($insertSQL, $myconnet) 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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<table align="center">
<tr valign="baseline">
<td nowrap="nowrap" align="right">Id:</td>
<td><input type="text" name="id" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right">Name:</td>
<td><input type="text" name="name" value="" size="32" /></td>
</tr>
<tr valign="baseline">
<td nowrap="nowrap" align="right"> </td>
<td><input type="submit" value="Insert record" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>
<p> </p>
</body>
</html>
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2016-04-05 10:25:52 2016-04-05 12:03:42 2016-04-05 12:04:31
|
 |
 |
 |
 |
Date :
2016-04-05 10:17:04 |
By :
auyjunk |
View :
1729 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เช็ค time in ถ้ามีแล้วก็ update time out แต่ถ้าไม่มี ก็ insert time in ลองทำตามดูนะครับ
|
 |
 |
 |
 |
Date :
2016-04-05 14:56:51 |
By :
mangkunzo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เคยมีท่านนึงแนะนำไว้ แยกตารางชื่อพนักงาน กับตารางบันทึกเข้า-ออก ออกจากกัน
สมมุติ นาย ตู่ มี id ที่ 1 เวลา นายตู่มาบันทึกเข้าก็ส่ง id=1 ไป insert เอาเวลาเข้าไป insert
พอ นาย ตู่ จะกลับ ต้องออก ก็เอา id นาย ตู่ ไปค้นหาล่าสุด
ถ้าเจอ นาย ตู่ มีค่าว่าง ก็ให้ update เวลาออก ของนาย ตู่ ตาม id ล่าสุดที่ นาย ตู่ เข้ามา
ตรงเขา - ออก นี่ นั่งจินตนาการ เขียน ขั้นตอนการเข้า แบบไหน การออกแบบไหน ได้เป็นฉาก ๆ เลยครับ
หรือ จะแยก ตารางชื่อ ตารางเข้า ตารางออก ทำได้หมดครับ คิดเยอะๆ คิดหลายๆแบบ เขียนขั้นตอนการทำงาน เขียนโปรแกรมสนุกครับ
|
 |
 |
 |
 |
Date :
2016-04-05 15:14:28 |
By :
apisitp |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไปต่อไม่ได้ครับ
|
 |
 |
 |
 |
Date :
2016-04-21 10:34:03 |
By :
auyjunk |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|