【发布时间】:2017-03-30 09:47:34
【问题描述】:
<?php
include( 'connect.php');
$query = mysqli_query($conn, "select * from users") or die( "unable to connect"); ?>
<html>
<head>
</head>
<body>
<h2 align="center"> student list</h2>
<form action="radio.php" method="post">
<table align="center" border="1" cellspacing="0" cellpadding="0" width="700">
<thead>
<td align='center'>id</td>
<td align='center'>enrolloment_no</td>
<td align='center'>first_name</td>
<td align='center'>last_name</td>
<td align='center'>attendance </td>
</thead>
<?php
$i=1;
while ( $row = mysqli_fetch_array($query, MYSQLI_BOTH) ) {
echo "<tr>
<td align='center'>" . @$i . "</td>
<td align='center'>" . @$row[ 'enrolloment_no' ] . "</td>
<td align='center'>" . @$row[ 'first_name'] . "</td>
<td align='center'>" . @$row[ 'last_name'] . "</td>
<td align='center'>
<input type=\"hidden\" value=\" " . $row['enrolloment_no'] . "\" name=\"rowIDs[]\" />
<input type=\"radio\" name=\"a_ " . $row['enrolloment_no'] . "\" value=\"present\">present
<input type=\"radio\" name=\"a_ " . $row['enrolloment_no'] . "\" value=\"absent\">absent
</td>
</tr>";
$i++;
}
?>
</table>
<input type="submit" value="submit">
</form>
</body>
</html>
以上是出勤页面的代码,现在我想将学生的出勤率,即每个学生的出勤率连同其注册号一起提交到数据库中,以便任何机构可以帮助我。
我也尝试了一些东西来总结,它看起来像下面提到的......
<?php
$rowIDs = $_POST['rowIDs'];
foreach( $rowIDs as $rowID ) {
$radioButtonValue = $_POST['a_' . $rowID ];
$b = mysqli_query(@$conn, "update `adding` SET `masterAttendance` = '" . $radioButtonValue .
"' WHERE `enrolloment_no` = '" . $rowID.
"'");
}
?>
**
错误:警告:mysqli_query() 期望参数 1 为 mysqli,null 在第 7 行的 C:\wamp64\www\demo\radio.php 中给出
**
【问题讨论】:
-
警告:mysqli_query() 期望参数 1 为 mysqli,在第 7 行的 C:\wamp64\www\demo\radio.php 中给出的 null 会显示此类错误
-
你是在第二页添加到数据库的连接吗?