abc

Share This blog with your friends, so that we can improve more & more . our aim is to easy & simple way of learning.

6/10/2018

updating mysql data using php

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,
<?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 .
in case error pass mysqli_error in connection.

An Introduction to the Laravel Framework: What It Is and Why You Should Use It

  If you're a PHP developer looking for a modern, efficient, and powerful framework to build web applications, look no further than Lara...