I am having trouble updating the values of an multidimensional associative array. The array $people has been generated from another MySQL call. With :
array_push($people, array("forename" => $pat_f_name, "surname" => $pat_s_name,"id" => $id)); I have set $forname and $surname to "", just to have the key there.
I am trying to iterate though the array making an SQL call and retrieve the relevant forename and surname and then update the keys at that index of the array.
Below is my attempt so far.
Thanks in advance.
$stmt = $mysql->stmt_init();
foreach ($people as $person)
{
if($stmt->prepare("SELECT forename,surname FROM worker WHERE id = ?"))
{
$stmt->bind_param('i', $p_id);
$p_id = $person["id"];
$stmt->execute();
$stmt->bind_result($f_name, $s_name);
while($stmt->fetch())
{
$people[$person]["forename"] = $f_name;
$people[$person]["surname"] = $s_name;
}
}
}
$stmt->close();
$person is an array
this
should output:
Warning: Illegal offset type in ….
and
output
better