我已经问了类似这样的问题。但我没有得到答案。但现在我实施了一些东西,然后发布。
这是我的 JAVASCRIPT
$(document).ready(function(){
$("#loginbutt").click(function() {
var servertime = $("#timer1").text();
var dataString = 'Current Time='+ servertime;
$.ajax({
type: "POST",
url: "inset_intime.php",
action: "insert",
data:dataString ,
cache: false,
beforeSend: function(html) {
document.getElementById("lastfive").innerHTML = '';
},
success: function(html){
$("#lastfive").append(html);
}
});
});
});
这是 inset_intime.php代码
include("config.php");
include("lock.php");
if(isset($_POST['loginbutt']))
{
$sql = "INSERT INTO emp_atten( fulldate,dayname,empname,empintime,status) VALUES (NOW(),'MON','$user_check',CURTIME(),'open')";
$result = mysql_query($sql);
}
if(isset($_POST['logoutbutt']))
{
$updatesql ="UPDATE Persons SET empoutimte=CURTIME() WHERE fulldate=NOW() AND empname='$user_check'";
$result = mysql_query($updatesql);
}
$new_sql= "SELECT fulldate,dayname,empname,empintime,empouttime,status FROM emp_atten WHERE empname='$user_check'order by fulldate asc limit 0, 5";
$rsd = mysql_query($new_sql);
echo "<table width='100%' border='0' cellspacing='1' cellpadding='5'>
<thead>
<tr>
<th width='15%'><div align='left'>DAY - DATE</div></th>
<th width='26%'><div align='left'>Employee Name</div></th>
<th width='19%'><div align='left'>In Time</div></th>
<th width='20%'><div align='left'>Out Time</div></th>
<th width='20%'><div align='left'>Status</div></th>
</tr>
</thead>
<tbody>
";
while($row = mysql_fetch_array($rsd))
{
echo "<tr>";
echo "<td>". $row[1]."-". $row[0] . "</td>";
echo "<td>" . $row[2] . "</td>";
echo "<td>" . $row[3] . "</td>";
echo "<td>" . $row[4] . "</td>";
echo "<td>" . $row[5] . "</td>";
echo "</tr>";
}
echo "</tbody></table>";
我得到了桌子。但数据没有更新,也没有插入。当我手动更新服务器中的数据时,它会显示在表格中,但是当点击lo-gin按钮时,它无法正常工作。