Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 用mysql和php保存考勤记录逻辑_Javascript_Php_Html_Mysql_Logic - Fatal编程技术网

Javascript 用mysql和php保存考勤记录逻辑

Javascript 用mysql和php保存考勤记录逻辑,javascript,php,html,mysql,logic,Javascript,Php,Html,Mysql,Logic,我正在设计一个签到系统,它将显示所有“体操运动员”在“选择类”下拉列表中设置的值以及他们自己的复选框(使用AJAX和JSON显示)。都是“帅哥多莉” 伪形式: <form> <classes dropdown populated from classes table onchange="ajaxFunction()"> <save button> </form> 然后,用户将选中所有在场体操运动员的方框,并将方框留给缺席体操运动员 点击保存按钮时

我正在设计一个签到系统,它将显示所有“体操运动员”在“选择类”下拉列表中设置的值以及他们自己的复选框(使用AJAX和JSON显示)。都是“帅哥多莉”

伪形式:

<form>
<classes dropdown populated from classes table onchange="ajaxFunction()">
<save button>
</form>
然后,用户将选中所有在场体操运动员的方框,并将方框留给缺席体操运动员

点击保存按钮时;我不知道如何将每个体操运动员的出场记录保存为课堂出勤表中的一个记录:

课堂出勤率(id、classid、体操运动员、出席人数[y/n],日期时间)

我知道这可能不是解决问题的最佳方法,但是有没有办法为表单中包含的数据创建一个数组,以便将其插入课堂出勤表,并将每个体操运动员的出席情况保存为记录


提前谢谢你的帮助

据我所知,我使用HTML、Jquery和PHP编写了脚本。看看代码是否适合你

HTML和Jquery代码

    <form action="process.php"  method="post">

<div>  
GymnastName  <input type="checkbox"  class="atd" ><br>
 <!-- put gymnastid in value what you getting from JSON -->
<input type="hidden" name="Gymnast_id[]" value='1' class="atdid">
<input type="hidden" name="Gymnast_attend[]" value='n' class="atdval">  
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='2' class="atdid">
<input type="hidden" name="Gymnast_attend[]"  value='n' class="atdval">  
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='3' class="atdid">
<input type="hidden" name="Gymnast_attend[]" value='n'class="atdval">    
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='4' class="atdid">   
<input type="hidden" name="Gymnast_attend[]" value='n'class="atdval">    
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"><br>
<input type="hidden" name="Gymnast_id[]" value='5' class="atdid">  
<input type="hidden" name="Gymnast_attend[]" value='n' class="atdval">  
</div><br>
  <input type="submit" name="Save">
</form>

<script
              src="https://code.jquery.com/jquery-2.2.4.min.js"
              integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
              crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function() {
     $('.atd').change(function() {
        if($(this).is(":checked")) {
          $(this).closest('div').find('.atdval').val('y'); 
        }
        else{

            $(this).closest('div').find('.atdval').val('n');
        }        
    });
});

<script>

体操运动员名称

体操运动员名称

体操运动员名称

体操运动员名称

体操运动员名称

$(文档).ready(函数(){ $('.atd').change(函数(){ 如果($(this).is(“:checked”)){ $(this).closest('div').find('.atdval').val('y'); } 否则{ $(this).closest('div').find('.atdval').val('n'); } }); });
PHP代码(process.PHP)



你大概只存储在场的人@保持缺席记录和在场记录一样重要。谢谢你的“有用”评论。谢谢你的讽刺。那么你可以将数组作为postdata发布吗?太棒了!是的,我们能做到,亲爱的:)
    <form action="process.php"  method="post">

<div>  
GymnastName  <input type="checkbox"  class="atd" ><br>
 <!-- put gymnastid in value what you getting from JSON -->
<input type="hidden" name="Gymnast_id[]" value='1' class="atdid">
<input type="hidden" name="Gymnast_attend[]" value='n' class="atdval">  
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='2' class="atdid">
<input type="hidden" name="Gymnast_attend[]"  value='n' class="atdval">  
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='3' class="atdid">
<input type="hidden" name="Gymnast_attend[]" value='n'class="atdval">    
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"> <br>
<input type="hidden" name="Gymnast_id[]" value='4' class="atdid">   
<input type="hidden" name="Gymnast_attend[]" value='n'class="atdval">    
</div><br>

<div>
GymnastName  <input type="checkbox"  class="atd"><br>
<input type="hidden" name="Gymnast_id[]" value='5' class="atdid">  
<input type="hidden" name="Gymnast_attend[]" value='n' class="atdval">  
</div><br>
  <input type="submit" name="Save">
</form>

<script
              src="https://code.jquery.com/jquery-2.2.4.min.js"
              integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
              crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function() {
     $('.atd').change(function() {
        if($(this).is(":checked")) {
          $(this).closest('div').find('.atdval').val('y'); 
        }
        else{

            $(this).closest('div').find('.atdval').val('n');
        }        
    });
});

<script>
<?php
$Gymnast_id=$_POST['Gymnast_id'];
$Gymnast_attend=$_POST['Gymnast_attend'];
foreach ($Gymnast_id as $key => $id) {

echo "Id: ".$id."<br>";
echo "Attend: ".$Gymnast_attend[$key]."<br><hr>";

// here you get id of Gymnast and present status, default it is "n"
// you can add your sql query here
//class-attendance(id, classid, gymnastid, present[y/n],datetime) 
}
?>