I want to embed a foreach() loop inside my SQL query as follows:
$query = "UPDATE $table
SET " . foreach ($_REQUEST as $field => $value) {
echo ("$field='$value'" . ", ");
}
echo ("$last_key='$last_value'"); . // popped from array to avoid trailing comma
"WHERE student_id = $student_id";
This results in a completely blank page so there is an error in the above code somewhere (page displays properly when above code snippet is commented out), or is what I am trying to do impossible?
The foreach() loop above works perfectly outside the UPDATE statement.