我正在创建一个学生出勤系统,我已经使用循环生成了来自mysql数据库的学生列表,现在使用单选按钮来获取他们的出勤率,即。存在或不存在,如何将他们的出勤数据保存到另一个sql数据库中。 这是我在php中的代码:
mysqli_select_db($db,'registration');
$sql = "SELECT name FROM student_database ";
$retval = mysqli_query($db , $sql );
if(! $retval )
{
die('Could not get data: ' . mysqli_error());
}
echo"<table class='data-table' width='100%' border='0' cellpadding='0' cellspacing='1' >
<tbody>";
$c=1;
while($row = mysqli_fetch_array($retval, MYSQLI_ASSOC))
{
echo"<p>";
echo"<tr>";
echo"<td height='50' class='data-table'>$c</td>" ;
echo "<td height='50' class='data-table'>{$row['name']}</td>" ;
echo"<form action=insert.php >";
echo"<td height='50' >";
echo "<label class='container'>
<input type='radio' name = 'attn' value='P' >
PRESENT
<span class='checkmark'></span>
</label>" ;
echo "<label class='container' >
<input type='radio' name = 'attn' value='A' >
ABSENT
<span class='checkmark'></span>
</label>" ;
echo"</td>";
echo"</form>";
echo"</tr>";
echo"</p>";
echo"<br/>";
$c++;
}
echo"</tbody>";
echo"</table>";
echo"<input type = 'submit' class='btn2' value = 'insert' >";