我不知道這是否合適就在這裏,因爲它更是一個認識問題對我的一部分,但I''m好奇,想知道爲什麼我收到這樣的輸出:數據重複輸入
Response id: 3 Question id: 1 Question: What is my middle name? Title: How Well Do You Know Michael
Array ([0] => Array ([0] => 3 [r_id] => 3 [1] => 1 [question_id] => 1 [2] => What is my middle name? [question] => What is my middle name? [3] => How Well Do You Know Michael [title] => How Well Do You Know Michael))
當我運行這個PHP腳本:
// Grab the response data from the database to generate the form
$query = "SELECT qr.response_id AS r_id, qr.question_id, q.question, quiz.title " .
"FROM quiz_response AS qr " .
"INNER JOIN question AS q USING (question_id) " .
"INNER JOIN quiz USING (quiz_id) " .
"WHERE qr.user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query) or die("MySQL error: " . mysqli_error($dbc) . "<hr>\nQuery: $query");
$questions = array();
while ($row = mysqli_fetch_array($data)) {
echo 'Response id: ' . $row['r_id'] . 'Question id: ' . $row['question_id'] . ' Question: ' . $row['question'] . ' Title: ' . $row['title'] . '<br />';
array_push($questions, $row);
}
print_r($questions);
它好像有每段數據的兩個條目。例如,在索引[0]和[r_id]下有兩個「Response id」條目。兩者相等3. 難道我擔心我陣列中的重複數據是否令人不安?當我每次做10個查詢時,我正在考慮未來,這是否會影響速度或準確性。任何輸入,非常感謝!
感謝澄清! – Abundnce10