내 페이지에는 종업원 ID 및 유형 인 2 가지 값이 있으며 유형은 내부 및 외부에 있습니다. 학생이 mysql에 시간에 맞게 삽입 된 값을 선택하고 학생이 out time column에 삽입 된 값을 선택하면. 하지만 제 경우에는 그렇지 않았습니다. 그 다음에 학생 ID 1에 삽입 된 시간에는 내가 선택한 학생이있을 때마다 다른 부분에 들어가서 이미 추가되었음을 보여줍니다. 모두를 위해 업데이트 된 시간은 모든 사람을 위해 삽입되지 않았으므로 이것을 위해 나를 도와주세요.다른 학생에게만 해당되는 Else 조건을 실행 한 후 첫 번째 학생을위한 시간 삽입 표 삽입. 그래서 나를 도와주세요.
<?php
session_start();
$branch=$_SESSION['branch'];
include('../dist/includes/dbcon.php');
$emp_id = $_POST['emp_id'];
$type = $_POST['type'];
//echo $type;
$query2=mysqli_query($con,"select in_time,emp_id from emp_a")or die(mysqli_error($con));
//$count=mysqli_num_rows($query2);
while($row=mysqli_fetch_array($query2))
{
$in = $row['in_time'];
$id = $row['emp_id'];
}
//echo $in;
if($type == 'In' && is_null($in))
{
mysqli_query($con,"INSERT INTO emp_a(emp_id,att_date,in_time,status) VALUES('$emp_id',curdate(),now(),1)")or die(mysqli_error($con));
echo "<script type='text/javascript'>alert('Successfully added time log!');</script>";
}
elseif($type == 'Out')
{
mysqli_query($con,"update emp_a set out_time = now(),status = 1 where emp_id = '$emp_id' and att_date=curdate()")or die(mysqli_error($con));
echo "<script type='text/javascript'>alert('Leaving Time added!');</script>";
}
else
{
echo "<script type='text/javascript'>alert('No!');</script>";
}
echo "<script>document.location='home.php'</script>";
?>
나는'$의 in' 당신이 뭘 하려는지의 모르겠지만,'$ id'은 항상 마지막 레코드 내가 진입 시간을 추가 할 시간이 존재 –
선택 쿼리에서 반환해야합니다 그래서 모든 학생들을 위해 나는 html과 php 페이지를 만들었습니다. 학생 이름을 표시하고 입력 할 때와 입력 할 때 학생이 시간을 선택하면 삽입 쿼리가 완성되고 형식이 바뀌어 시간에 대한 쿼리가 업데이트됩니다. 그러나 내 경우에는 첫 번째 학생 만이 다른 학생에게 돌아가서 수행되었으므로 다른 부분에 참여하여 나에게 성명을 발표하지 않았습니다. –