I have a multi-dimensional array in which it’s inner arrays vary in length(linkl) …line 13-15.
The inner arrays are suppose to update rows in a table.
The SQL query in line 35 tries to do that…
I am trying though to make a prepared statement for that…and I cannot construct the code to cater for the fact that the inner arrays vary in length…currently I am stuck in the bind_param expression…this is where I am:
foreach ($servicedta as $update)
{
$update = array_intersect_key($update, $allowed);
$id = array_pop($update);//το update κρατάει τα values προς updating και το allowed το maximum κάθε φορά
$set = [];
foreach ($update as $field => $value) {
$set[] = "`{$field}`=:{$value}";
}
if($stmt=$connection->prepare('UPDATE services_list SET"' . implode(', ', $set). '" WHERE serviceID="'.$id))
{
$stmt->bind_param(str_repeat("s", count($set)+1),$service,$price,$price_show,$ID);//problem here
}
}
the problem lies in the variable definition…the number of it must vary accordingly.
within the foreach loop.
Any ideas?