Book Management Program (ii) _php tutorial

Source: Internet
Author: User
Tags set time
Book Catalogue input Section:
if (! $UploadAction):
?>
This procedure is for the entry of the title, author, publisher information and set up.
Editor: Kong Xiuxiang. Date: 2001/3/24
/*
Session_Start ();
if (!isset ($auth _passed)) {
echo "This feature is only available to authorized users. ";
return-1;
}

if (Isset ($u _name)) {
Session_name ($u _name);

echo " ". Session_name ().": This program will be happy to serve you. \ n ";
echo "";
}
*/
?>

<title>Book Catalogue input</title>







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; is not repeated.
$TimeLimit = 0; Set time-out limit when the default time is 30 seconds set to 0 is unlimited
Set_time_limit ($TimeLimit);
@MYSQL_CONNECT ($hostname, $dbusername, $dbpassword) OR die ("Cannot connect to the database! ");
@mysql_select_db ("$dbname") or Die ("Cannot select database! ");
$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 = "The title is required, other if the ISBN is empty, then the author's first and last name, the publisher is required."
Please check that the requirements are met. ";
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 "title". $count [1]. "
";
if (! $r) {
echo "Query is invalid
";
Exit
}
if (mysql_num_rows ($r)) {
if (Trim ($ISBN)! = "") {
echo "Data duplication.
";
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 "This book is already in the database.
";
echo "title:" $books _name;
echo "
Author: ". $first _name. $last _name;
echo "
GB Standard ISBN: ". $count [5];
echo "
Book Price: ". $count [6]." Yuan ";
echo "
Publication date: ". substr ($count [7],0,4)." Year ". substr ($count [7],5,2). Month ";
if ($count [8])
echo "page number:". $count [8]. " Page ";
Echo
Return ";
$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\ "";
$results 1 = @mysql_query ($s _publisher);
$count 1=mysql_fetch_array ($results 1);
if (mysql_num_rows ($results 1) <1) {
$q _publisher= "INSERT into Publisher (Publisher_name, address, zipcode, telephone, telefax, email) VALUES (\" $p _name\ ", \" $address \ ", \" $zipcode \ ", \" $telephone \ ", \" $telefax \ ", \" $email \ ")";
$result 2 = @mysql_query ($q _publisher);
if ($result 2) {
$publisher _id= mysql_insert_id ();
}
}
Else
$publisher _id= $count 1[0];
}

if ($b _name== "") {
echo "title cannot be empty. ";
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\ "";
$results 3 = @mysql_query ($s _books);
$count 3=mysql_fetch_array ($results 3);
if (Mysql_num_rows ($results 3) <1) {
$q _books= "INSERT into Books (Books_name, publisher_id, date_pub, type, pages, PRICE,ISBN) VALUES (\" $b _name\ ", \" $publish Er_id\ ", \" $date _pub\ ", \" $type \ ", \" $pages \ ", \" $b _price\ ", \" $ISBN \ ")";
$result 3 = @mysql_query ($q _books);
if ($result 3) {
$books _id= mysql_insert_id ();
}
}
Else
$books _id= $count 3[0];
}

if ($a _first1== "") | | ($a _last1== "")) {
echo "The first author's name cannot be empty. ";
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);
$count 2=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 _las T1\ ", \" $address \ ", \" $zipcode \ ", \" $telephone \ ", \" $email \ ")";
$result 1 = @mysql_query ($q _author);
if ($result 1) {
$author _id= mysql_insert_id ();
}
}
Else
$author _id = $count 2[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\ "";
$results 5 = @mysql_query ($s _author2);
$count 5=mysql_fetch_array ($results 5);
if (Mysql_num_rows ($results 5) <1) {
$q _author2= "INSERT into author (first_name, last_name, address, zipcode, telephone, email) VALUES (\" $a _first2\ ", \" $a _la St2\ ", \" $address \ ", \" $zipcode \ ", \" $telephone \ ", \" $email \ ")";
$result 2 = @mysql_query ($q _author2);
if ($result 2) {
$author _id= mysql_insert_id ();
}

}
Else
$author _id = $count 5[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\ "";
$results 6 = @mysql_query ($s _author3);
$count 6=mysql_fetch_array ($results 6);
if (Mysql_num_rows ($results 6) <1) {
$q _author3= "INSERT into author (first_name, last_name, address, zipcode, telephone, email) VALUES (\" $a _first2\ ", \" $a _la St2\ ", \" $address \ ", \" $zipcode \ ", \" $telephone \ ", \" $email \ ")";
$result 3 = @mysql_query ($q _author3);
if ($result 3) {
$author _id= mysql_insert_id ();
}

}
Else
$author _id = $count 6[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
Return ";
Echo";

?>
endif
?>

http://www.bkjia.com/PHPjc/315972.html www.bkjia.com true http://www.bkjia.com/PHPjc/315972.html techarticle Book catalogue input section:? if (! $UploadAction):??//This program is for the entry of the title, author, publishing materials and set. Editor: Kong Xiuxiang. Date: 2001/3/24/* session_start (); ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.