dsomm80482 2013-11-03 10:51
浏览 10

PHP中另一个文件中的动态复选框值访问

i am facing problem i am developing school system in php. i want use checkbox dynamic for attendance but checkbox value i cant use in another file please help me

first file attendacne.php

    <form name="abc" method="post" action="attendance-con.php">
    <p>Date: 
    <input name="dat" type="text" class="tcal"/>
    <input name="Save" type="submit"  style="float:right 20ox;" value="Save Attendace" />
    <input name="class_id" type="hidden" value="<?php echo $_REQUEST['class_id']; ?> " />
    <?php

    $a=0;
    $qry=("SELECT DISTINCT
    s.rollnum as rollnum,
    s.std_name as name 
    FROM  student s WHERE s.std_class=".$_REQUEST['class_id']."");
    $result=mysql_query($qry);
    while($row=mysql_fetch_array($result))
    {
    ?>
    <table width="100%" border="1" align="center" cellpadding="4" cellspacing="4" style="text-align:left;" id="stname">
    <?php
    if($a==0)
    { ?>     
    <tr>
    <th width="117" height="39" bgcolor="#FFE1CC">Student RollNo</th>
    <th bgcolor="#FFE1CC">Student Name</th>
    <th width="100" bgcolor="#ECFAFF">Present</th>
    </tr>
    <?php 
    }?>
    <?php
    if($a==1)
    { ?>
    <tr>
    <th width="117" height="-5" bgcolor="#FFE1CC"></th>
    <th bgcolor="#FFE1CC"></th>
    <th width="100" bgcolor="#ECFAFF"></th>
    </tr>
    <?php
    }
    ?>
    <?php $a=1; ?>
    <input type="hidden" name="rollnum[]" value="<?php echo $row['rollnum'];?>"/><tr>
<td> 
    <?php echo $row['rollnum'];?>
</td>
<td>
    <?php echo $row['name'];?>
</td>
<td>
    <input type="checkbox" name="stid[]" value="1">
</td>
    </tr>
    <?php }?>
    </table>
    </form>

second file attendance-con.php

    <?php
include_once("include/config.php");
    $i=0;
    $Dat=$_POST['dat'];
    $cid=$_POST['class_id'];

    $sid=$_POST['stid'];

    foreach($_POST['rollnum'] as $x)
    {
    if($sid[$i]=='1')
{
    $query=mysql_query("INSERT INTO attendance (sid,cid,Date,status)
    values('$x','$cid','$Dat','1')");
}
    if($sid[$i]!='1')
{
    $query=mysql_query("INSERT INTO attendance (sid,cid,Date,status)
    values('$x','$cid','$Dat','0')");
}
    $i=$i+1;      
    }
    ?>
  • 写回答

1条回答 默认 最新

  • dongyuan1984 2013-11-03 11:55
    关注
    <input type="checkbox" name="stid" value="1">
    

    not

    <input type="checkbox" name="stid[]" value="1">
    
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。