Page Stats
Visitor: 493
PHP MySql Update
In PHP, we can execute a update MySql statement to update records in the database table. First we need to create a MySql connection, write the sql update query, execute the query and to update records.
Example 1: Create a MySql connection, execute the update query to update records in the MySql table.
<?php
$conn = mysqli_connect("localhost", "root" , "", "student");
if($conn === false){
die("ERROR: Could not connect to database.");
}
$sql = "update book set class=3 where id=3";
$result = mysqli_query($conn, $sql);
if($result==1)
echo "record updated";
else
echo "error";
mysqli_close($conn);
?>
Advertisement