if(isset($_GET['edit_id'])){
$sql="SELECT * FROM info WHERE id=" .$_GET['edit_id'];
$result= mysqli_query($connect, $sql);
$row = mysqli_fetch_array($result);
}
//update
if(isset($_POST['btn-update'])){
$name=$_POST['name'];
$suname=$_POST['surname'];
$age=$_POST['age'];
$result=$_POST['result'];
$log=$_POST['log'];
$update="UPDATE employeeinfo SET name='$name', surname='$surname' WHERE id=". $_GET['edit_id'];
$up= mysqli_query($connect, $update);
if(!isset($sql)){
die("Error $sql" .mysqli_connect_error());
}
else
{
header("location: record.php");
}
}
和我的召唤
<html>
<body>
<h1>edit info<h1>
<form method="post">
name:<input type="text" class="form-control" name="name" value="<?php echo $row['name']; ?>"><br><br>
surname: <input type="text" name="surname" placeholder="Surname" value="<?php echo $row['surname']; ?>"><br><br>
log: <input type="text" name="log" placeholder="0" value="<?php echo $row['log']; ?>"><br><br>
<button type"submit" name"btn-update" id="btn-update" onclick="update()"><strong>Update</strong></button>
<a href="record.php"><button type="button" value="button">Cancel</button></a>
</form>
<script>
function update(){
var x;
if(confirm("Updated data Successfully") == true){
x = "update";
}
}
</script>
甚至不确定该脚本是否有任何作用,因为我的提示说“更新成功”但显然它不是。一如既往地谢谢你们