0
exam_paper{
exam_paper_id,
exam_paper_name
}
question{
question_id,
question,
option1,
option2,
option3,
option4,
answer
}
exam_question_list{
id,
exam_paper,id,
question_id
}
exampaper.php如何使用复选框
<a href="addquestions_to_exampaper.php?id=<?php echo $row3["exam_paper_id"];?>">
<button id="addques"><i class="fa fa-plus-circle"></i> Add Questions</button>
</a>
addquestions_to_exampaper.php
<?php
$sql= "SELECT * FROM question WHERE catergory_id=$catergory_id AND level_id=1";
$result=mysqli_query($dbcon,$sql);
?>
<form method="post" action="addquestions_to_exampaper_action.php?exid=<?php echo $exam_paper_id;?>">
<table>
<caption>Easy Level Questions</caption>
<thead>
<tr>
<th scope="col">Question ID</th>
<th scope="col">Question</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($result)){
?>
<tr>
<td data-label="Question Id"><input name="question_id" value="<?php echo $row['question_id'];?>" readonly type="checkbox" /></td>
<td data-label="Question" style="text-align:left"><?php echo $row['question']; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
<input type="submit" value="Add Question" name="submit" id="submit" />
</form>
addquestions_to_exampaper_action.php
来将数据添加到表行<?php
include '../../db/db_connection.php';
if(isset($_POST['submit'])){
$exam_paper_id=$_GET['exid'];
$question_id=$_POST['question_id'];
$sql="INSERT INTO exam_question_list (exam_paper_id,question_id) VALUES ('$exam_paper_id','$question_id')";
if (mysqli_query($dbcon,$sql)){
header("Location: exampaper.php");
exit();
}else{
$error=mysqli_error($dbcon);
}
}
?>
我有q问题池。 (问题表) 我需要通过选择复选框来添加问题,并且需要向问题论文添加问题。(exam_question_list表格)
当我选择复选框的数量并点击添加按钮时,只有一个复选框数据发送到'exam_question_list表',其他选中的复选框数据没有消失。
如何解决此错误?
我想数据,如低于 exam_question_list
**id exam_paper_id question_id**
1 1 12
2 1 3
3 1 45
4 1 5
for循环中有错误 –
什么是错误? –
解析错误:在G:\ xampp \ htdocs \ WBES \ src \ system \ modules \ exam \ addquestions_to_exampaper_action.php中预期变量(T_VARIABLE)或'$'出现语法错误,错误代码为 –