我想更新editentries.php中输入的详细信息。但当我输入详细信息并单击更新时,它并没有在数据库中更新。我正在使用replace查询来完成它。帮帮我,我该怎么办?
这是editentries.php
if(isset($_POST['edit']) && isset($_POST['editid'])){
$id = $_POST['editid'];
$selectname=mysqli_query($conn,"SELECT * FROM feedetails where id = $id GROUP BY name");
$selectaddress=mysqli_query($conn,"SELECT * FROM feedetails where id = $id GROUP BY address");
$selectemail=mysqli_query($conn,"SELECT * FROM feedetails where id = $id GROUP BY email");
$selectphoneno=mysqli_query($conn,"SELECT * FROM feedetails where id = $id GROUP BY phoneno");
$selectprice=mysqli_query($conn,"SELECT * FROM feedetails where id = $id GROUP BY price");
?>
<div class="col-lg-10 col-md-10 col-sm-10"><br><br><br>
<h2>Update Applicant Details</h2><hr>
<div class="col-lg-8 col-md-8 col-sm-8">
<form method="post" action="entries.php">
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label">Applicant ID:</label>
<div class="col-sm-10">
<?php
echo '<input type="text" class="form-control" id="inputEmail3" name="id" readonly value="'.$id.'">';
?>
</div>
</div>
<div class="form-group row">
<label for="inputEmail3" class="col-sm-2 col-form-label">Name:</label>
<div class="col-sm-10">
<?php while($res=mysqli_fetch_array($selectname)){
echo '<input type="text" class="form-control" id="inputEmail3" name="name" value="'.$res['name'].'">';
}
?>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 col-form-label">Address:</label>
<div class="col-sm-10">
<?php while($res=mysqli_fetch_array($selectaddress)){
echo '<textarea class="form-control" id="inputEmail3" name="address">'.$res['address'].'</textarea>';
}
?>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 col-form-label">Phone no.:</label>
<div class="col-sm-10">
<?php while($res=mysqli_fetch_array($selectphoneno)){
echo '<input type="text" class="form-control" id="inputEmail3" name="phoneno" value="'.$res['phoneno'].'">';
}
?>
</div>
</div>
<div class="form-group row">
<label for="inputPassword3" class="col-sm-2 col-form-label">Email ID:</label>
<div class="col-sm-10">
<?php while($res=mysqli_fetch_array($selectemail)){
echo '<input type="text" class="form-control" id="inputEmail3" name="email" value="'.$res['email'].'">';
}
?>
</div>
</div>
<div class="form-group row">
<div class="col-sm-10">
<input type="submit" class="btn btn-primary" name="update" value="Update">
</div>
</div>
<?php
if(isset($_POST["id"]) && isset($_POST["name"]) && isset($_POST["address"]) && isset($_POST["phoneno"]) && isset($_POST["email"]) && isset($_POST['update']))
{
$sid= $_POST["id"];
$name= $_POST["name"];
$address=$_POST["address"];
$phoneno= $_POST["phoneno"];
$email= $_POST["email"];
$update="REPLACE INTO feedetails(id,subjects,price,name,address,email,phoneno) VALUES ('$sid','$name','$address','$email','$phoneno')";
if(mysqli_query($conn,$update))
{
echo " <SCRIPT LANGUAGE='Javascript'>
window.alert('Record updated');
window.location.href='entries.php';
</SCRIPT>";
}
else
{
mysqli_error($conn);
}
}
} ?>
我想在数据库中更新该特定id的详细信息,但它根本不起作用
4条答案
按热度按时间nuypyhwy1#
“更新您的表集name='$name',address='$address',email='$email',phoneno='$phoneno',其中id='$sid'”
oalqel3c2#
example:-
tvz2xvvm3#
使用ajax&jquery将id添加到提交按钮,即id=“delsub”,而不是提交delete以返回javascript
在deleteentry.php中,将$\u请求更改为$\u post
balp4ylt4#
sql中的replace函数用于更新字符串的内容,而不是用于更新数据。
可以使用sql update语句。
所以你的sql查询是这样的,
$update=“update feedetails set name=”..$name.”,address=”..$address.”,email=“”..$email.”,phoneno=“”..$phoneno.”,其中id=“”..$id;