PHP開發(fā)簡單圖書后臺管理系統(tǒng)新書管理修改刪除
繼續(xù)引入數(shù)據(jù)庫文件config.php文件
和判斷管理員是否登錄的ly_check.php文件
在HTML頁面中調(diào)用css.css樣式
刪除功能文件設(shè)置為del.php文件
<?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 "刪除失敗"; ?>
修改功能設(shè)置成update.php文件
<?php include("config.php"); require_once('ly_check.php'); ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>圖書管理系統(tǒng)新書修改</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() 函數(shù)從結(jié)果集中取得一行,并作為枚舉數(shù)組返回。一條一條獲取,輸出結(jié)果為$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>