How can I put the results of a MySQLi prepared statement into an associative array?
I have a sql query and a mysqli prepared statement: $sql = 'SELECT photographers.photographer_id, photographers.photographer_name FROM photographers'; $stmt = $conn->stmt_init(); if ($stmt->prepare($sql)) { $stmt->bind_result($photographer_id, $photographer_name); $OK = $stmt->execute(); $stmt->fetch(); } How can I store the results in an associative array so I can loop it later and get to all the data returned by the sql string? Chris Try the following: $meta = $statement->result_metadata(); while ($field = $meta->fetch_field()) { $params[] = &$row[$field->name]; } call_user_func_array(array(