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)或'$'出現語法錯誤,錯誤代碼爲 –