⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 update_item.php

📁 一个用php+mysql做的图书馆管理系统
💻 PHP
字号:
<?php
/**************************************************************************************

    Simple Library System
    Copyright (C) 2002 John Mark Matthews

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    For further information, contact:
    	John Matthews
    	jmatthews@exostrategy.com

***************************************************************************************/

include("mainfile.inc");
include("header.inc");
include("footer.inc");
include("auth.inc");

reg('GET','item_id');
reg('POST','submit', 'item_id', 'item_type', 'title', 'author', 'subject', 'abstract', 'update_item', 'delete_item', 'item_id');

if($global_is_admin) {
	if($item_type && $title && $item_id && $update_item) {
		$sql = "update tbl_item set ";
		$sql.= "item_type=$item_type,";
		$sql.= "title='$title',";
		$sql.= "subject='$subject',";
		$sql.= "abstract='$abstract',";
		$sql.= "author='$author', ";
		$sql.= "status=1 ";
		$sql.= "where item_id=$item_id";
		mysql_query($sql);
		head();
		menu();
		echo "<p><b>You have updated the following item:</b></p>";
		PrintItem($item_id);
		foot();
	}else if($item_id && $delete_item) {
		$sql = "update tbl_item set ";
		$sql.= "item_type=$item_type,";
		$sql.= "title='$title',";
		$sql.= "subject='$subject',";
		$sql.= "abstract='$abstract',";
		$sql.= "author='$author', ";
		$sql.= "login_id=null, ";
		$sql.= "status=4 ";
		$sql.= "where item_id=$item_id";
		mysql_query($sql);
		head();
		menu();
		echo "<p><b>You have removed the following item:</b></p>";
		PrintItem($item_id);
		foot();
	}else if($item_id) {
		$sql = "select * from tbl_item where item_id=$item_id";
		$r = mysql_query($sql);
		$line = mysql_fetch_array($r);
		head();
		menu();
		$t="";
		$t = MakeSelectArray("select item_type, item_type_desc from tbl_item_type order by item_type");

		$subject_list="";
		$subject_list = MakeSelectArray("select subject, subject from tbl_subject order by subject");

		OpenForm("","Language='JavaScript' onSubmit='if (confirm(\"Are you sure you want to update/remove this item?\")) { return true; } else { return false; }'");
		OpenTable();
		echo "
		<tr><td valign=top> Type: </td><td> ".MakeSelect("item_type",$line["item_type"],$t)." </td>
		<tr><td valign=top> Title: </td><td> <input name='title' type='text' size=60 value='".$line["title"]."'> </td></tr>
		<tr><td valign=top> Author: </td><td> <textarea wrap='virtual' cols='50' rows='3' name='author'>".htmlspecialchars($line["author"],ENT_QUOTES)."</textarea> </td></tr>
		<tr><td valign=top> Subject: </td><td> ".MakeSelect("subject",$line["subject"],$subject_list)." </td>
		<tr><td valign=top> Abstract: </td><td> <textarea wrap='virtual' cols='50' rows='12' name='abstract'>".htmlspecialchars($line["abstract"],ENT_QUOTES)."</textarea> </td></tr>
		<tr><td colspan='4' align='center'> <input type='hidden' name='item_id' value=$item_id></td></tr>
		<tr><td colspan='4' align='center'> <input align='center' name='update_item' type='submit' value = 'Update Item'></td></tr>
		<tr><td colspan='4' align='center'> <input align='center' name='delete_item' type='submit' value = 'Remove Item'></td></tr>
		";
		CloseTable();
		CloseForm();
		foot();
	}
}else{
	header("Location: ./index.php");
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -