I'm trying to make a prepared statement that has a variable amount of input variables. for example:
$sql = "INSERT INTO MyGuests (firstname, lastname, email, tel) VALUES (?, ?, ?, ?)";
$types = "ssss";
$result_array = array of four different strings
$update = $conn->prepare($sql);
$update->bind_param($types,$result_array);
I know that this won't work but it's an example
note:
result_array, types and the fields in $sql always have the same amount as eachother
So if result_array has 5 values then $types and the values in $sql would also have 5
but it could variable in my code so 5 values could also be 6 or 2 values
so my question is:
Is it possible to have a variable amount of input values in an prepared statement