Note that there are some explanatory texts on larger screens.

plurals
  1. PODuplicated data entries in PHP array
    primarykey
    data
    text
    <p>I'm not sure if this appropriate on here since it is more of a understanding issue on my part but I''m curious to know why I receive this output:</p> <pre><code>Response id: 3 Question id: 1 Question: What is my middle name? Title: How Well Do You Know Michael Array ( [0] =&gt; Array ( [0] =&gt; 3 [r_id] =&gt; 3 [1] =&gt; 1 [question_id] =&gt; 1 [2] =&gt; What is my middle name? [question] =&gt; What is my middle name? [3] =&gt; How Well Do You Know Michael [title] =&gt; How Well Do You Know Michael ) ) </code></pre> <p>when I run this PHP script:</p> <pre><code>// 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) . "&lt;hr&gt;\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'] . '&lt;br /&gt;'; array_push($questions, $row); } print_r($questions); </code></pre> <p>It seems as though there are two entries for each piece of data. For example, there are two entries of the 'Response id' under index [0] and [r_id]. Both equal 3. <strong>Is it a delirious fear of mine worrying about duplicated data in my array?</strong> I'm thinking of the future when I'm doing 10's of queries at a time and whether this will affect speed or accuracy. Any input is greatly appreciated!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload