Answers for "update from database php"

PHP
1

php update sql database from form

<?php

include "config.php"; // Using database connection file here

$id = $_GET['id']; // get id through query string

$qry = mysqli_query($db,"select * from emp where id='$id'"); // select query

$data = mysqli_fetch_array($qry); // fetch data

if(isset($_POST['update'])) // when click on Update button
{
    $fname = $_POST['fname'];
    $lname = $_POST['lname'];
	
    $edit = mysqli_query($db,"update emp set fname='$fname', lname='$lname' where id='$id'");
	
    if($edit)
    {
        mysqli_close($db); // Close connection
        header("location:all_records.php"); // redirects to all records page
        exit;
    }
    else
    {
        echo mysqli_error();
    }    	
}
?>

<h3>Update Data</h3>

<form method="POST">
  <input type="text" name="fname" value="<?php echo $data['fname'] ?>" placeholder="Enter Full Name" Required>
  <input type="text" name="lname" value="<?php echo $data['lname'] ?>" placeholder="Enter Last Name" Required>
  <input type="submit" name="update" value="Update">
</form>
Posted by: Guest on August-25-2021
2

live update mysql data in php

$(document).ready(function(){    
    loadstation();
});

function loadstation(){
    $("#station_data").load("station.php");
    setTimeout(loadstation, 2000);
}
Posted by: Guest on August-22-2020
-1

update php

//SQL query for updating php post from a form using sql
$firstName = $_POST['firstName'];
mysqli_query($con,"UPDATE member SET  firstName='$firstName' WHERE id=1");

or 
// actually updating php version
go contact hosting provider, or login to cpanl look for 'php' settings or 'MultiPHP Manager'
Posted by: Guest on May-26-2021

Browse Popular Code Answers by Language