我試圖從我的表'問題'中測驗ID($ currentQuizID)是相同的結果的所有行。我的代碼只允許我從表中獲取單行數據,那麼我該怎麼做?如何從表中的不同行獲取多個結果?
$findQuiz = "SELECT QuizID FROM quiz ORDER BY QuizID DESC";
$result = mysqli_query($user->db,$findQuiz);
$iddata = mysqli_fetch_array($result);
$currentQuizID = $iddata['QuizID'];
$findQuestions = "SELECT Type, Question, Answer FROM question WHERE QuizID = '".$currentQuizID."'";
$result2 = mysqli_query($user->db,$findQuestions);
$iddata2 = mysqli_fetch_array($result2);
echo $iddata2[0];
echo $iddata2[1];
echo $iddata2[2];
它們放在一個while循環。 –
while($ row = mysqli_fetch_array($ result2)){ $ questions [] = $ rows ['type']; } add while循環獲取多條記錄。 –
@ L.Herrera我會如何寫它? –