hi in this session give detail about how update current data
for eg: name is mayur and actual in database kumar. for this purpose we use update query.
let us see,
in case error pass mysqli_error in connection.
for eg: name is mayur and actual in database kumar. for this purpose we use update query.
let us see,
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "employee";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "UPDATE hello SET lastname='shahgadh' WHERE id=2";
if (mysqli_query($conn, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
in above example we see to update lastname whose id is 2 if it success then show message .$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "employee";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "UPDATE hello SET lastname='shahgadh' WHERE id=2";
if (mysqli_query($conn, $sql)) {
echo "Record updated successfully";
} else {
echo "Error updating record: " . mysqli_error($conn);
}
mysqli_close($conn);
?>
in case error pass mysqli_error in connection.