我正在用 php 设计一个考勤模块。要使用 php 中的单选按钮标记出勤率,我正在使用表单并将其发布到其他网页。
表格代码:-
<form method="POST" action="marked.php">
<p align="center">
<center><h2>Your Subject Students</h2></center>
<?php
$link=mysql_connect("mysql4.000webhost.com","a2101142_jxpolre","jxplor1") or die("Cannot Connect to the database!");
mysql_select_db("a2101142_login",$link) or die ("Cannot select the database!");
$query="SELECT sid,sname FROM studentdetails s,facultydetails f WHERE ( s.sub1=f.subid OR s.sub2=f.subid OR s.sub3=f.subid) AND f.fid=$id";
$resource=mysql_query($query,$link);
echo "<table align=\"center\" border=\"0\" width=\"70%\">
<tr><td><b>S.No.</b></td> <td><b>Student ID</b></td> <td><b>Name</b></td> <td><b>Present</b></td> <td><b>Absent</b></td></tr> ";
$x=0;
while($result=mysql_fetch_array($resource))
{ $x++;
echo "<tr><td>".$x."</td><td>".$result[0]."</td><td>".$result[1]."</td><td><input type='radio' name='attend[$result[0]]' value='Present'></td><td><input type='radio' name='attend[$result[0]]' value='Absent'></td></tr>";
} echo "</table>";
?>
<center><input type='submit' name='Submit' value='Submit'>   <input type="reset" value="Reset"/></center>
</form>
Marked.php 代码:-
<?php
print_r($_POST);
?>
这里我正在接收输出:- Array ( [attend] => Array ( [2202] => Present [2203] => Present [2204] => Present [2208] => Present [2210] => Present [2211] => 现在 [2216] => 现在 [2217] => 现在 [2218] => 现在)[提交] => 提交)
如何将 $id 和 Present/Absent 与 $_POST() 分开?请帮忙????/