ContinueIntroduce the database file config.php file
and the ly_check.php file that determines whether the administrator is logged in
in the HTML page Call the css.css style
Delete the function file and set it to the del.php file
<?php include("config.php"); require_once('ly_check.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 "删除失败"; ?>
Modify the function setting to the update.php file
<?php include("config.php"); require_once('ly_check.php'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>图书管理系统新书修改</title> <link rel="stylesheet" href="css.css" type="text/css"> <script type="text/javascript"> <!-- function myform_Validator(theForm) { if (theForm.name.value == "") { alert("请输入书名。"); theForm.name.focus(); return (false); } if (theForm.price.value == "") { alert("请输入书名价格。"); theForm.price.focus(); return (false); } if (theForm.type.value == "") { alert("请输入书名所属类别。"); theForm.type.focus(); return (false); } return (true); } //--></script> </head> <?php $sql="select * from yx_books where id='".$_GET['id']."'"; $arr=mysqli_query($link,$sql); $rows=mysqli_fetch_row($arr); //mysqli_fetch_row() 函数从结果集中取得一行,并作为枚举数组返回。一条一条获取,输出结果为$rows[0],$rows[1],$rows[2]....... ?> <?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>"; } } ?> <body> <form id="myform" name="myform" method="post" action="" onSubmit="return myform_Validator(this)"> <table width="100%" height="173" border="0" align="center" cellpadding="2" cellspacing="1" class="table"> <tr> <td colspan="2" align="left" class="bg_tr"> 后台管理 >> 新书修改</td> </tr> <tr> <td width="31%" align="right" class="td_bg">书名:</td> <td width="69%" class="td_bg"> <input name="name" type="text" id="name" value="<?php echo $rows[1] ?>" size="15" maxlength="30" /> </td> </tr> <tr> <td align="right" class="td_bg">价格:</td> <td class="td_bg"> <input name="price" type="text" id="price" value="<?php echo $rows[2]; ?>" size="5" maxlength="15" /> </td> </tr> <tr> <td align="right" class="td_bg">入库时间: </td> <td class="td_bg"> <label> <input name="uptime" type="text" id="uptime" value="<?php echo $rows[3] ; ?>" size="17" /> </label> </td> </tr> <tr> <td align="right" class="td_bg">所属类别: </td> <td class="td_bg"><label> <input name="type" type="text" id="type" value="<?php echo $rows[4]; ?>" size="6" maxlength="19" /> </label></td> </tr> <tr> <td align="right" class="td_bg">入库总量:</td> <td class="td_bg"><input name="total" type="text" id="total" value="<?php echo $rows[5]; ?>" size="5" maxlength="15" /> 本</td> </tr> <tr> <td align="right" class="td_bg"> <input type="hidden" name="action" value="modify"> <input type="submit" name="button" id="button" value="提交"/></td> <td class="td_bg"> <input type="reset" name="button2" id="button2" value="重置"/></td> </tr> </table> </form> </body> </html>