Question:medium

Which function is used to fetch a single row from a MySQL query result as an associative array?

Show Hint

The word assoc in the name signals column-name keys, which is what associative means.
Updated On: Jul 2, 2026
  • mysqli_fetch_row()
  • mysqli_fetch_array()
  • mysqli_fetch_assoc()
  • mysqli_fetch_object()
Show Solution

The Correct Option is C

Solution and Explanation

Idea: Read each function name as what its result is keyed by.

row means numeric index, so fetch_row gives $[0,1,2]$. object means a class instance accessed with the arrow operator. array is the mixed default. assoc directly names the associative form, where the key is the column name:
\[ \text{result}[\text{column\_name}] = \text{value} \]
The one function whose sole purpose is a column-keyed single row is mysqli_fetch_assoc().
\[\boxed{\text{Option C: mysqli\_fetch\_assoc()}}\]
Was this answer helpful?
0