what if I want to update data via prepared stmt each query loop, but why fails. the error msg is "All data must be fetched before a new statement prepare takes place "
$link = mysqli_connect("localhost", "admin", "", "test");
if (!$link) {
die('Connect Error: ' . mysqli_connect_error());
}
//field_1 is PK
if ($stmt = mysqli_prepare($link, "SELECT field_1, field_2 FROM table_data")) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $col1, $col2);
while (mysqli_stmt_fetch($stmt)) {
$updateC= "update table_data set field_3=? where field_1=?"
if ($stmt2= mysqli_prepare($link, $updateC)) {
mysqli_stmt_execute($stmt2);
$status='test'; //get return value from function
mysqli_stmt_bind_param($stmt2, 'ss', $status, $col1);
}
mysqli_stmt_close($stmt2);
}
mysqli_stmt_close($stmt);
}
mysqli_close($link);