我对代码的实际作用感到困惑。
我知道它是从数据库中获取这些字段,然后更新为新值。
但特别是,这行是做什么的“ if(isset($_POST['new']) && $_POST['new']==1)
”
我的老师给了我们这段代码,并告诉我们对其进行修改而无需解释。
<?php
$status = "";
if(isset($_POST['new']) && $_POST['new']==1)
{
$id=$_REQUEST['id'];
$title =$_REQUEST['title'];
$genre =$_REQUEST['genre'];
$released =$_REQUEST['released'];
$platforms =$_REQUEST['platforms'];
$publisher =$_REQUEST['publisher'];
$image =$_REQUEST['image'];
$review =$_REQUEST['review'];
$buynow =$_REQUEST['buynow'];
$update="update gameinfo set title='".$title."',
genre='".$genre."',
released='".$released."',platforms='".$platforms."',
publisher='".$publisher."', image='".
$image."', review='".$review."', buynow='".$buynow."'
where id='".$id."'";
$conn->query($update) or die(mysqli_error());
$status = "Record Updated Successfully. </br></br><a
href='view.php'>View Updated Record</a>";
echo '<p style="color:#00FF00;">'.$status.'</p>';
} else {
?>
感谢您的帮助。谢谢