作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我希望代码将相同的值插入到列表中检查的不同行(该列表是从数据库查询的。)但它说
“注意:第 5 行\enrol.php 中的数组到字符串转换”,
这是我的section.php
<table border=1px>
<th>SELECT</th>
<th>ID NUMBER</th>
<th>NAME</th>
<th>COURSE</th>
<th>YEAR</th>
<?php session_start();
include('connect.php');
$group=$_REQUEST['idEdit'];
echo $group;
$sql="SELECT * FROM login WHERE section IS NULL or section = 0";
$result=mysql_query($sql) or die(mysql_error() );
while($arr=mysql_fetch_array($result))
{
echo '<tr><td><form action="enrol.php" method="post"><input type="checkbox" name="idnumber[]" value="'.$arr['idnumber'].'"></td>'.
'<td>'.$arr['idnumber'].", </td>".
'<td>'.$arr['lastname'].",".$arr['firstname']." </td>".
'<td>'.$arr['course']." </td>".
'<td>'.$arr['year']." </td></tr>";}
$idnumber=$arr['idnumber'];
?>
<input type="hidden" value="<?php $group ?>" name="group">
<input type="submit" value="Enrol Student" name="submit">
</form>
</table>
这是我的 enrol.php
<?php
if(isset($_REQUEST['submit'])){
$ids = join (', ', $_POST['idnumber']);
$sql="INSERT INTO login (section) values ('$_POST[group]') WHERE idnumber='$ids'";
mysql_query($sql);
$count=mysql_affected_rows();
if($count==1){
echo '<script type="text/javascript">alert("Added Sucessfully")</script>';
}else{
echo '<script type="text/javascript">alert("Error!")</script>';
}
}
?>
我该如何解决这个问题?我一直在尝试寻找解决方案,但似乎找不到任何解决方案。请帮忙。
最佳答案
我认为,您得到的隐藏字段组值为空。首先,您在隐藏字段中回显组值。
<input type="hidden" value="<?php echo $group; ?>" name="group">
希望您的问题能够得到解决。你明白我的意思了吗?
关于php - 如何将一个值插入到不同的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15785264/
我是一名优秀的程序员,十分优秀!