36 Program to update data in MySQL Database using PHP.

Program:

<?php

    $host = "localhost";

    $user = "root";

    $pass = "1234";

    $dbname = "employees";



    $conn = mysqli_connect($host,$user,$pass,$dbname);



    if(!$conn)

    {

        die('Could Not Connect:'.mysqli_errort());

    }

       

    echo "Connected Successfully: <br>";

    $id = 1;

    $salary = 20000;

    $sql = "Update emp set Salary=$salary where id=$id";

   

    if(mysqli_query($conn,$sql))  

    {

        echo "Record Updated Successfull";

    }

    else

    {

        echo "Could not update record: ".mysqli_error($conn);  

    }

   

    mysqli_close($conn);   

?>


Output:

Program to update data in MySQL Database using PHP.

Previous
Next Post »