請參考下面的圖片:PHP - 如何選擇由mysqli_fetch_array()給出的行的特定索引?
http://i.stack.imgur.com/6hBPC.png
例如,如果用戶點擊該行的按鈕,說:「你有數學測驗」時,認爲「問答ID」值行然後會被傳遞給另一個PHP文件。
這裏是我當前的代碼:
<?php
$con=mysqli_connect("127.0.0.1", "root", "", "quizmaker");
if (mysqli_connect_errno($con))
{
echo "MySqli Error: " . mysqli_connect_error();
}
$now=date("m/d/Y");
$sql=mysqli_query($con,"SELECT * FROM quiz_query WHERE quiz_date='$now'");
$count=mysqli_num_rows($sql);
if($count>=1)
{
echo "<table border='1' width='50%'>";
echo "<form action='answer_quiz.php' method='post'>";
echo "<tr>
<td>You have a pending quiz!</td><td> </td><td> </td>
</tr>";
$number=1;
while($result=mysqli_fetch_array($sql))
{
echo "<tr>";
echo "<td>You have a quiz for " . $result['subject'] . "</td>";
echo "<td>Quiz ID: " .$result['quiz_ID']. "</td>";
echo "<td><input type='submit' name='button' id='button' value='Take Quiz'>";
echo "<input type='hidden' name='quiz[$number]' value='$result[quiz_ID]'>";
echo "</td>";
echo "</tr>";
$number++;
}
echo "</form>";
echo "</table>";
}
else
{
"You have no quiz! :D";
}
mysqli_close($con);
?>
歡迎SO!你能提供更多關於你在找什麼的信息嗎?你是否遇到錯誤?您沒有列出上述代碼的明確問題。 – Derek
謝謝您的關注,但問題已解決。 :) –