已标记his/her次出勤的学生按下标记出勤按钮后无法再次标记
Student which mark his/her attendance once can't mark it again when mark attendance button is pressed
我的目标:一旦按钮被按下,就不能再按下了。它应该给出错误或某种消息(当第一次按下按钮以标记出勤并且有人再次按下它时)
" attendance is already marked you cannot mark your attendance again "
<?php
session_start();
?>
<form method="post">
<button name="attendence" >mark attendence </button>
</form>
<?php
if (isset($_POST['attendence'])){
$id =$_SESSION["id"];
$con = mysqli_connect('localhost','root','','yo');
$query = "INSERT INTO attendance (present,absent, datetime, std_id) VALUES ('present','',current_timestamp(), $id ) ";
$rs=mysqli_query($con,$query);
if($rs){
echo "Marked as Present";
}
else {
echo "marked as Absent";
}
}
如果学生已被此代码标记为出席,您必须在数据库中搜索:
$id =$_SESSION["id"];
$query = "SELECT * FROM attendance WHERE std_id = '$id' ) ";
$result=mysqli_query($con,$query);
while ($row = mysqli_fetch_assoc($result)) {
if ($row['present'] == 'present') {
echo' Student already marked as present';
}
else {
echo'
<form method="post">
<button name="attendence" >mark attendence </button>
</form>';
}
}
首先:如果学生已经 marked/present,则在数据库中搜索。如果 he/she 存在,则回显“写点东西”。
然后:插入查询以标记 present
<?php
if (isset($_POST['attendence'])){
$id =$_SESSION["id"];
$con = mysqli_connect('localhost','root','','yo');
$mark_query = "SELECT * FROM `attendance` WHERE date=CURRENT_DATE and std_id=$id ";
$result = mysqli_query($con, $mark_query);
$row = mysqli_fetch_assoc($result);
if ($row['present']=='present') {
echo "Student already marked ".$row['present'];
}
else{
$query = "INSERT INTO attendance (present,absent, datetime, std_id,date,marked_status) VALUES ('present','',current_timestamp(), $id, current_timestamp(),'marked' ) ";
$rs=mysqli_query($con,$query);
if($rs){
echo "Marked as Present";
}
}
}
?>
我的目标:一旦按钮被按下,就不能再按下了。它应该给出错误或某种消息(当第一次按下按钮以标记出勤并且有人再次按下它时)
" attendance is already marked you cannot mark your attendance again "
<?php
session_start();
?>
<form method="post">
<button name="attendence" >mark attendence </button>
</form>
<?php
if (isset($_POST['attendence'])){
$id =$_SESSION["id"];
$con = mysqli_connect('localhost','root','','yo');
$query = "INSERT INTO attendance (present,absent, datetime, std_id) VALUES ('present','',current_timestamp(), $id ) ";
$rs=mysqli_query($con,$query);
if($rs){
echo "Marked as Present";
}
else {
echo "marked as Absent";
}
}
如果学生已被此代码标记为出席,您必须在数据库中搜索:
$id =$_SESSION["id"];
$query = "SELECT * FROM attendance WHERE std_id = '$id' ) ";
$result=mysqli_query($con,$query);
while ($row = mysqli_fetch_assoc($result)) {
if ($row['present'] == 'present') {
echo' Student already marked as present';
}
else {
echo'
<form method="post">
<button name="attendence" >mark attendence </button>
</form>';
}
}
首先:如果学生已经 marked/present,则在数据库中搜索。如果 he/she 存在,则回显“写点东西”。 然后:插入查询以标记 present
<?php
if (isset($_POST['attendence'])){
$id =$_SESSION["id"];
$con = mysqli_connect('localhost','root','','yo');
$mark_query = "SELECT * FROM `attendance` WHERE date=CURRENT_DATE and std_id=$id ";
$result = mysqli_query($con, $mark_query);
$row = mysqli_fetch_assoc($result);
if ($row['present']=='present') {
echo "Student already marked ".$row['present'];
}
else{
$query = "INSERT INTO attendance (present,absent, datetime, std_id,date,marked_status) VALUES ('present','',current_timestamp(), $id, current_timestamp(),'marked' ) ";
$rs=mysqli_query($con,$query);
if($rs){
echo "Marked as Present";
}
}
}
?>