热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

图书管理程序(二)

图书管理程序(二)
图书目录输入部分:
if(!$UploadAction):
?>
//本程序是为输入书名,作者、出版社资料而设。
//编者:孔秀祥。日期:2001/3/24
/*
session_start();
if (!isset($auth_passed)) {
echo "本功能只有授权用户才能使用。";
return -1;
}

if(isset($u_name)) {
session_name($u_name);

//echo "
".session_name().":本程序将竭诚为您服务。
\n";
//echo "
";
}
*/
?>




ACTION= "" METHOD = "POST">
















著作名
作者
作者
作者
编著方式

定价.
出版社
出版日期

ISBN

有关书的说明












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

$b_price=trim($b_price_a)."\.".trim($b_price_b);
if(strlen($p_month)==1)
$p_mOnth="0".trim($p_month);
if($p_mOnth=="")
$p_mOnth="01";
$date_pub=trim($p_year)."-".trim($p_month)."-01";

$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";

$b_name=trim($b_name);
$sele="select books.books_id, books.books_name,author.first_name,author.last_name,publisher.publisher_name,books.ISBN,books.price,books.date_pub,books.pages";
$fro=" from books,author,books_author,publisher ";
if(trim($isbn)!="")
$whe="where books.ISBN=\"$isbn\" ";
elseif(trim($a_first1)!="" && trim($a_last1)!="" && trim($p_name)!="")
$whe=" 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";
else{
$msg="书名为必填,其他如果ISBN为空,则作者的姓、名,出版社为必填。
请检查是否符合要求。";
xueroom_error_exit($msg,$PHP_SELF);

}
$q="$sele$fro$whe";

/*
books.books_id,
books.books_name,
author.first_name,
author.last_name,
publisher.publisher_name
books.ISBN,
books.price,
books.date_pub,
books.pages
*/
$r = @mysql_query($q);
// $count=@mysql_fetch_row($r);
// echo "书名".$count[1]."
";
if(!$r){
echo "查询无效
";
exit;
}
if(mysql_num_rows($r)){
if(trim($isbn)!=""){
echo "数据重复。
";
exit;
}
else
while($count=mysql_fetch_array($r)){
/*
echo "while。
";
echo trim($a_first1);
echo trim($count[2]);
echo trim($a_first1)==trim($count[2]);
echo "
";
echo trim($a_last1)==trim($count[3]);
echo "
";
echo trim($p_name)==trim($count[4]);
echo "
";
*/
if( trim($a_first1)==trim($count[2]) && trim($a_last1)==trim($count[3]) && trim($p_name)==trim($count[4])){
$data_exist+=1;
$books_id=$count[0];
$books_name=$count[1];
$first_name=$count[2];
$last_name=$count[3];
$repeat=1;
echo "本书已经在数据库中。
";
echo "书名:".$books_name;
echo "
作者:".$first_name.$last_name;
echo "
国标标准书号:".$count[5];
echo "
书价:".$count[6]."元";
echo "
出版日期:".substr($count[7],0,4)."年".substr($count[7],5,2)."月";
if($count[8])
echo "页码:".$count[8]."页";
echo"
返回 ";
//$repeat=0;
exit;
// break;
}
}//while($count=mysql_fetch_array($r)){
}//if(mysql_num_rows($r){


//if(!$repeat){

if($p_name!=""){
$p_name=trim($p_name);
$address=trim($address);
$zipcode=trim($zipcode);
$telephOne=trim($telephone);
$telefax=trim($telefax);
$email=trim($email);
$s_publisher="select publisher_id from publisher where publisher_name=\"$p_name\"";
$results1 = @mysql_query($s_publisher);
$count1=mysql_fetch_array($results1);
if(mysql_num_rows($results1)<1){
$q_publisher="INSERT INTO publisher (publisher_name, address, zipcode, telephone, telefax, email) VALUES (\"$p_name\", \"$address\", \"$zipcode\", \"$telephone\", \"$telefax\", \"$email\")";
$result2 = @mysql_query($q_publisher);
if($result2){
$publisher_id= mysql_insert_id();
}
}
else
$publisher_id= $count1[0];
}

if($b_name==""){
echo"书名不能为空。";
exit;
}
else{
$b_name=trim($b_name);
$publisher_id=trim($publisher_id);
// $date_pub=trim($date_pub);
$type=trim($type);
$pages=trim($pages);
// $b_price=trim();
$isbn=trim($isbn);
$s_books="select books_id from books where books_name=\"$b_name\" ";
$results3 = @mysql_query($s_books);
$count3=mysql_fetch_array($results3);
if(mysql_num_rows($results3)<1){
$q_books="INSERT INTO books (books_name, publisher_id, date_pub, type, pages, price,ISBN) VALUES (\"$b_name\", \"$publisher_id\", \"$date_pub\", \"$type\", \"$pages\", \"$b_price\",\"$isbn\")";
$result3 = @mysql_query($q_books);
if($result3){
$books_id= mysql_insert_id();
}
}
else
$books_id=$count3[0];
}

if(($a_first1=="")||($a_last1=="")){
echo"第一作者的姓名不能为空。";
//exit;
}
else{
$a_first1=trim($a_first1);
$a_last1=trim($a_last1);
$address=trim($address);
$zipcode=trim($zipcode);
$telephOne=trim($telephone);
$email=trim($email);
$s_author="select author_id from author where first_name=\"$a_first1\" and last_name=\"$a_last1\"";
$results = @mysql_query($s_author);
$count2=mysql_fetch_array($results);
if(mysql_num_rows($results)<1){
$q_author="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first1\", \"$a_last1\", \"$address\", \"$zipcode\", \"$telephone\", \"$email\")";
$result1 = @mysql_query($q_author);
if($result1){
$author_id= mysql_insert_id();
}
}
else
$author_id =$count2[0];

if($books_id!=""||$author_id!=""){
$s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
$resulta = @mysql_query($s_ba);
//$counta=mysql_fetch_array($resulta);
if(mysql_num_rows($resulta)<1){
$q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
$author_id="";
$resulta = @mysql_query($q_books_author);
}
}
}
if(($a_first2!="")||($a_last2!="")){
$a_first2=trim($a_first2);
$a_last2=trim($a_last2);
$s_author2="select author_id from author where first_name=\"$a_first2\" and last_name=\"$a_last2\"";
$results5 = @mysql_query($s_author2);
$count5=mysql_fetch_array($results5);
if(mysql_num_rows($results5)<1){
$q_author2="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first2\", \"$a_last2\", \"$address\", \"$zipcode\", \"$telephone\", \"$email\")";
$result2 = @mysql_query($q_author2);
if($result2){
$author_id= mysql_insert_id();
}

}
else
$author_id =$count5[0];
if($books_id!=""||$author_id!=""){
$s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
$resulta = @mysql_query($s_ba);
//$counta=mysql_fetch_array($resulta);
if(mysql_num_rows($resulta)<1){
$q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
$author_id="";
$resulta = @mysql_query($q_books_author);
}
}

}
if(($a_first3!="")||($a_last3!="")){
$a_first3=trim($a_first3);
$a_last3=trim($a_last3);
$s_author3="select author_id from author where first_name=\"$a_first3\" and last_name=\"$a_last3\"";
$results6 = @mysql_query($s_author3);
$count6=mysql_fetch_array($results6);
if(mysql_num_rows($results6)<1){
$q_author3="INSERT INTO author (first_name, last_name, address, zipcode, telephone, email) VALUES (\"$a_first2\", \"$a_last2\", \"$address\", \"$zipcode\", \"$telephone\", \"$email\")";
$result3 = @mysql_query($q_author3);
if($result3){
$author_id= mysql_insert_id();
}

}
else
$author_id =$count6[0];
if($books_id!=""||$author_id!=""){
$s_ba="select id from books_author where books_id=\"$books_id\" and author_id=\"$author_id\"";
$resulta = @mysql_query($s_ba);
//$counta=mysql_fetch_array($resulta);
if(mysql_num_rows($resulta)<1){
$q_books_author="INSERT INTO books_author (books_id, author_id, author_type) VALUES (\"$books_id\", \"$author_id\", \"$author_type\")";
$author_id="";
$resulta = @mysql_query($q_books_author);
}
}

}

echo"
返回 ";
echo"";

?>
endif;
?>
推荐阅读
  • 本文介绍了在开发Android新闻App时,搭建本地服务器的步骤。通过使用XAMPP软件,可以一键式搭建起开发环境,包括Apache、MySQL、PHP、PERL。在本地服务器上新建数据库和表,并设置相应的属性。最后,给出了创建new表的SQL语句。这个教程适合初学者参考。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • 如何实现织梦DedeCms全站伪静态
    本文介绍了如何通过修改织梦DedeCms源代码来实现全站伪静态,以提高管理和SEO效果。全站伪静态可以避免重复URL的问题,同时通过使用mod_rewrite伪静态模块和.htaccess正则表达式,可以更好地适应搜索引擎的需求。文章还提到了一些相关的技术和工具,如Ubuntu、qt编程、tomcat端口、爬虫、php request根目录等。 ... [详细]
  • Monkey《大话移动——Android与iOS应用测试指南》的预购信息发布啦!
    Monkey《大话移动——Android与iOS应用测试指南》的预购信息已经发布,可以在京东和当当网进行预购。感谢几位大牛给出的书评,并呼吁大家的支持。明天京东的链接也将发布。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • PHP设置MySQL字符集的方法及使用mysqli_set_charset函数
    本文介绍了PHP设置MySQL字符集的方法,详细介绍了使用mysqli_set_charset函数来规定与数据库服务器进行数据传送时要使用的字符集。通过示例代码演示了如何设置默认客户端字符集。 ... [详细]
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 本文介绍了如何使用php限制数据库插入的条数并显示每次插入数据库之间的数据数目,以及避免重复提交的方法。同时还介绍了如何限制某一个数据库用户的并发连接数,以及设置数据库的连接数和连接超时时间的方法。最后提供了一些关于浏览器在线用户数和数据库连接数量比例的参考值。 ... [详细]
  • Oracle Database 10g许可授予信息及高级功能详解
    本文介绍了Oracle Database 10g许可授予信息及其中的高级功能,包括数据库优化数据包、SQL访问指导、SQL优化指导、SQL优化集和重组对象。同时提供了详细说明,指导用户在Oracle Database 10g中如何使用这些功能。 ... [详细]
  • 本文讨论了如何优化解决hdu 1003 java题目的动态规划方法,通过分析加法规则和最大和的性质,提出了一种优化的思路。具体方法是,当从1加到n为负时,即sum(1,n)sum(n,s),可以继续加法计算。同时,还考虑了两种特殊情况:都是负数的情况和有0的情况。最后,通过使用Scanner类来获取输入数据。 ... [详细]
  • 原文地址:https:www.cnblogs.combaoyipSpringBoot_YML.html1.在springboot中,有两种配置文件,一种 ... [详细]
  • Windows下配置PHP5.6的方法及注意事项
    本文介绍了在Windows系统下配置PHP5.6的步骤及注意事项,包括下载PHP5.6、解压并配置IIS、添加模块映射、测试等。同时提供了一些常见问题的解决方法,如下载缺失的msvcr110.dll文件等。通过本文的指导,读者可以轻松地在Windows系统下配置PHP5.6,并解决一些常见的配置问题。 ... [详细]
  • Metasploit攻击渗透实践
    本文介绍了Metasploit攻击渗透实践的内容和要求,包括主动攻击、针对浏览器和客户端的攻击,以及成功应用辅助模块的实践过程。其中涉及使用Hydra在不知道密码的情况下攻击metsploit2靶机获取密码,以及攻击浏览器中的tomcat服务的具体步骤。同时还讲解了爆破密码的方法和设置攻击目标主机的相关参数。 ... [详细]
  • 本文介绍了C#中数据集DataSet对象的使用及相关方法详解,包括DataSet对象的概述、与数据关系对象的互联、Rows集合和Columns集合的组成,以及DataSet对象常用的方法之一——Merge方法的使用。通过本文的阅读,读者可以了解到DataSet对象在C#中的重要性和使用方法。 ... [详细]
author-avatar
手机用户2602922383_687
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有