I have the following code snippet. The problem is that when I print out the results of the array, the data for the $results is the same. It should say [emaid_id] => 1 and [email_id] => 2.
How can I fix this problem?
I'm using this code:
$ex = $stmt->execute();
$stmt->store_result();
$results = array();
$allResults = array();
$params = array();
$meta = $stmt->result_metadata();
if ($meta)
{
while ($field = $meta->fetch_field())
{
$allResults[$field->name] = null;
$params[] = &$allResults[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
}
while ($stmt->fetch())
{
$results[] = $allResults;
}
$stmt->free_result();
print_r($results);
Output:
Array
(
[results] => Array
(
[0] => Array
(
[email_id] => 2
[email_sent] => 0
)
[1] => Array
(
[email_id] => 2
[email_sent] => 0
)
)
[success] => 1
[count] => 2
)