if语句条件失效
因为班上每周要做红领巾爱学习,在班级群不好统计,于是就写了这个,用户POST提交信息至数据库,在观看了指定时间就会在数据库标注为已完成。但在写判断时间的时候,if语句没满足条件就直接执行,(switch语句也试过了,没有用)以下是代码,谢谢各位!若对我有帮助,我会通过打赏的方式·给予1-3元的酬金
<html xmlns="http://www.w3.org/1999/xhtml">
<form name="myform">
<td valign="top" width="135">
<input name="clock" size="10" >
</td>
</form>
<head>
<?php
$conn = mysqli_connect('****', '****', '******', '****');
?>
<script type=“text/javascript”>
window.onbeforeunload = closing;
<?php
$name = $_POST['name'];
$int1 = $_POST["xuehao"];
$sql_select = "INSERT INTO `tab_h` (`name`, `xuehao`, `ok`) VALUES ('$name', '$int1', '未完成');";
$ret = mysqli_query($conn, $sql_select);
?>
</script>
<script language="JavaScript">
var id, iM = 0, iS = 0;
start = new Date();
function go() {
now = new Date();
time = (now.getTime() - start.getTime()) / 1000;
time = Math.floor(time);
iS = time % 60;
iM = Math.floor(time / 60);
if (iS < 10)
document.myform.clock.value = " " + iM + " 分 0" + iS + " 秒";
else
document.myform.clock.value = " " + iM + " 分 " + iS + " 秒";
id = setTimeout("go()", 1000);
}
go();
</script>
</head>
<body>
<?php
#判断从这里开始
$phpvar="<script>document.write(iM);</script>";
if ($phpvar>2#注:这个2加不加引号都试过了){
$sql_select = "DELETE FROM `tab_h` WHERE `name`=$name";
$ret = mysqli_query($conn, $sql_select);
$sql_select = "INSERT INTO `tab_h` (`name`, `xuehao`, `ok`) VALUES ('$name', '$int1', '已完成');";
$ret = mysqli_query($conn, $sql_select);
echo "OK";
}
#结束
?>
</body>
</html>