// Assume database connection has already been made $query = "SELECT * FROM users"; $result = mysqli_query($connection, $query); if(mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { echo "Name: " . $row["name"] . " Email: " . $row["email"]; } }
// Assume database connection has already been made $query = "UPDATE users SET age = 30 WHERE name='John'"; $result = mysqli_query($connection, $query); if($result) { echo "Age updated successfully."; } else { echo "Error updating age: " . mysqli_error($connection); }This example uses the mysqli extension in PHP to execute an UPDATE query on a table named "users". The resulting query result is a boolean indicating whether or not the query executed successfully. If the update was successful, a message is printed to the screen. Otherwise, an error message with the details of the error is displayed. Package library used: mysqli extension