欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

图书管理程序(三)

程序员文章站 2022-03-14 09:48:41
图书查询部分:
图书查询部分:
<?
if(!$uploadaction):
?>
<?
//本程序是为输出书名,作者、出版社资料而设。
//编者:孔秀祥。日期:2001/3/25
?>
<html><head>
<title>书目查询 </title>
</head>
<body><table align=center>
<form enctype= "multipart/form-data" name = "submitform"
action= "<? $php_self ?>" method = "post">
<input type= "hidden" name = "max_file_size" value ="20000000">
<input type= "hidden" name = "uploadaction" value = "1">

<!--tr><td>文件名<td><input name = "uploadfile" type = "file" value="" size = "30"></tr-->
<tr><td align=center>著作名<td><input name = "b_name" type = "text" value="" size = "30" maxlength=100></td></tr>
<tr><td align=center>作者<td>姓<input name = "a_first1" type = "text" value="" size = "6" maxlength=20>
名<input name = "a_last1" type = "text" value="" size = "6" maxlength=20></td></tr>
<tr><td align=center>出版社<td><input name = "p_name" type = "text" value="" size = "30" maxlength=100></td></tr>
<tr><td>出版日期<td><input name = "p_year" type = "text" value="" size = "4">年
<!--input name = "p_month" type = "text" value="" size = "2">月 <-->
<tr><td>isbn<td><input name = "isbn" type = "text" value="" size = "25">

</table><table align=center>
<tr><td align=center>
<input name = "submit" value = "提交" type = "submit">
<td><input name = "reset" value = "重置" type = "reset">
</td></tr>
</form></center></table></body>

</html>

<?

else:
session_start();
require "config.php3";

$b_price=$b_price_a.".".$b_price_b;

$uploadaction=0;
$repeat=0;      //是不是重复了。
$timelimit=0; //设置超时限制时间缺省时间为 30秒设置为0时为不限时
set_time_limit($timelimit);
@mysql_connect($hostname,$dbusername,$dbpassword) or die("不能连接数据库!");
@mysql_select_db("$dbname") or die("不能选择数据库!");
//$q="select books.books_id, books.books_name,author.first_name,author.last_name,publisher.publisher_name from books,author,books_author,publisher where books.books_name="$b_name" and books.publisher_id=publisher.publisher_id and books.books_id=books_author.books_id and books_author.author_id=author.author_id";
if($b_name!="")
    $bn="books.books_name="$b_name" and ";
if($p_name!="")
    $pn="publisher.publisher_name="$p_name" and ";
if($a_first1!="")
    $af="author.first_name="$a_first1" and ";
if($a_last1!="")
    $al="author.last_name="$a_last1" and ";
if($p_year!=""){
    $date_p="books.date_pub rlike '^$p_year.*' and ";
    }
if($isbn!="")
    $is="books.isbn="$isbn" and ";
$q="select books.books_id, books.books_name,author.first_name,author.last_name,publisher.publisher_name from books,author,books_author,publisher  
where $bn $pn $af $al $date_p $is books.publisher_id=publisher.publisher_id and books.books_id=books_author.books_id and books_author.author_id=author.author_id order by books.books_name";


$r = @mysql_query($q);
if(!$r){
    echo "查询无效 <br>";
    exit;
}
if(mysql_num_rows($r)<1){
    $msg="没有符合要求的记录。";
    xueroom_error_exit($msg,$php_self);

}

while($count=mysql_fetch_array($r)){  
    $books_id=$count[0];
    $books_name=$count[1];
    $first_name=$count[2];
    $last_name=$count[3];
    $publisher_name=$count[4];
    if($book!=$books_id){
        $repeat++;
        echo "<br>".$repeat."、";
        echo "《".$books_name."》";
        echo "出版社:".$count[4];
        echo "  作者:";
    }
    echo "$first_name$last_name ";
    $book=$books_id;
}

echo"<br><a href = $php_self>返回 </a>";
echo"</body></html>";

?>
<?
endif;
?>