国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

PHP develops simple book background management system with new book management, modification and deletion functions

This section explains the implementation of the "Modify" and "Delete" functions in the "New Book Management" page by selecting and clicking on the operation function.

Let's talk about the "Delete" function first.

The main idea is:

Get the id of the book to be deleted

46.png

Delete this book by deleting the id of this book through a SQL statement All records with id in the database.

<?php
$SQL ="DELETE FROM yx_books where id='".$_GET['id']."'";
$arry=mysqli_query($link,$sql);
if($arry){
  echo "<script> alert('刪除成功');location='list.php';</script>";
}
else
  echo "刪除失敗";
?>

Then there is the "Modify" function.

1623.png

Get the ID of the book that needs to be modified

Query all the IDs of this ID in the database through SQL statements information. Then modify the information of this id through SQL statements

<?php
$SQL = "SELECT * FROM yx_books where id='".$_GET['id']."'";
$arr=mysqli_query($link,$sql);
$rows=mysqli_fetch_row($arr);
?>
<?php
if($_POST['action']=="modify"){
  $sqlstr = "UPDATE yx_books SET name = '".$_POST['name']."', price = '".$_POST['price']."', uploadtime = '".$_POST['uptime']."', 
  type = '".$_POST['type']."', total = '".$_POST['total']."' where id='".$_GET['id']."'";
  $arry=mysqli_query($link,$sqlstr);
  if ($arry){
    echo "<script> alert('修改成功');location='list.php';</script>";
  }
  else{
    echo "<script>alert('修改失敗');history.go(-1);</script>";
  }

}
?>

Give the <from> form an onSubmit click event:

<form id="myform" name="myform" method="post" action="" onSubmit="return myform_Validator(this)">

Use < through the onSubmit click event ;javascript>When judging the modification of book information, each modified information cannot be left empty.

<script type="text/javascript">
  function myform_Validator(theForm)
  {

    if (theForm.name.value == "")
    {
      alert("請(qǐng)輸入書(shū)名。");
      theForm.name.focus();
      return (false);
    }
    if (theForm.price.value == "")
    {
      alert("請(qǐng)輸入書(shū)名價(jià)格。");
      theForm.price.focus();
      return (false);
    }
    if (theForm.type.value == "")
    {
      alert("請(qǐng)輸入書(shū)名所屬類別。");
      theForm.type.focus();
      return (false);
    }
    return (true);
  }
</script>


Continuing Learning
||
<?php $SQL = "SELECT * FROM yx_books where id='".$_GET['id']."'"; $arr=mysqli_query($link,$sql); $rows=mysqli_fetch_row($arr); ?> <?php if($_POST['action']=="modify"){ $sqlstr = "UPDATE yx_books SET name = '".$_POST['name']."', price = '".$_POST['price']."', uploadtime = '".$_POST['uptime']."', type = '".$_POST['type']."', total = '".$_POST['total']."' where id='".$_GET['id']."'"; $arry=mysqli_query($link,$sqlstr); if ($arry){ echo "<script> alert('修改成功');location='list.php';</script>"; } else{ echo "<script>alert('修改失敗');history.go(-1);</script>"; } } ?>
submitReset Code