mysql - Duplicated data entries in PHP array -


i'm not sure if appropriate on here since more of understanding issue on part i''m curious know why receive output:

response id: 3 question id: 1 question: middle name? title: how know michael array ( [0] => array ( [0] => 3 [r_id] => 3 [1] => 1 [question_id] => 1 [2] => middle name? [question] => middle name? [3] => how know michael [title] => how know michael ) )  

when run php script:

// grab response data database generate form     $query = "select qr.response_id r_id, qr.question_id, q.question, quiz.title " .           "from quiz_response qr " .           "inner join question 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); 

it seems though there 2 entries each piece of data. example, there 2 entries of 'response id' under index [0] , [r_id]. both equal 3. is delirious fear of mine worrying duplicated data in array? i'm thinking of future when i'm doing 10's of queries @ time , whether affect speed or accuracy. input appreciated!

if check out documentation of mysqli_fetch_array see second parameter $result_type default set mysql_both.

that means both numerical field index (mysql_num) , field name (mysql_assoc) used array-index. if need field name indices have use that:

while ($row = mysqli_fetch_array($data, mysql_assoc)) {     // .... 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -