我一直在研究这方面的事情,但我仍然无法编辑/更新我的参赛作品。注意,这是我的第一个真正的程序,我的水平有点平庸。所以我想就此事寻求你的建议/帮助。
CODE:
<?php
include('config.php');
if(isset($_POST['edit']))
{
$sql = "select * from hotels where BIL =" .$_GET['edit'];
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
}
if(isset($_POST['submit'])){
$hotel = $_POST['hotel'];
$address = $_POST['address'];
$update = "update hotels set $hotel = 'hotel', $address = 'address' where BIL = ".$_GET['edit'];
$up = mysqli_query($link, $update);
if (isset($sql)){
die ("Error $sql" .mysqli_connect_error());
}
else
{
header ("location: view.php");
}
}
?>
<html>
<body>
<form method="post" >
New Hotel: <br />
<textarea name="hotel" cols="50" rows="2" value="<?php echo $row['hotel']; ?>" /></textarea>
<br />
Address: <br / >
<textarea name="address" cols="50" rows="10" value="<?php echo $row['address']; ?>" /></textarea><br /><br />
<input type="submit" name="submit" value="update" />
</form>
<script>
function update(){
var x;
if(confirm("update Succesfully") == true){
x= "update";
}
}
</script>
</body>
</html>
额外注意:我从youtube频道复制了此代码... https://www.youtube.com/watch?v=jQzRDwY6zPc 提前谢谢!