Online Public Access Catalog For Library System

Online Public Access Catalog

If you are looking for Online Public Access Catalog for Library System or it's called OPAC then you are at the right place. We have a full source code for this kind of system Online Public Access Catalog for Library System is for viewing and providing information about books, authors, and category inside the library. This program works to provide the students the information of the book that we're gonna borrow, to know the status of the books inside the Library, and to know if the books are available or not. And, we display the image of the book in this program. The user can search by title, author, category, copyright year and the barcode of the books.

Creating our Table

For the first step, we are going to make our database. To create a database:
  1. Open PHPMyAdmin
  2. Create a database and name it as "opac_db".
  3. After creating a database name, click the SQL and kindly copy the code below.
  1. --
  2. -- Table structure for table `book`
  3. --
  4.  
  5. CREATE TABLE IF NOT EXISTS `book` (
  6. `book_id` int(11) NOT NULL AUTO_INCREMENT,
  7. `book_title` varchar(100) NOT NULL,
  8. `category_id` int(50) NOT NULL,
  9. `author` varchar(50) NOT NULL,
  10. `author_2` varchar(100) NOT NULL,
  11. `author_3` varchar(100) NOT NULL,
  12. `author_4` varchar(100) NOT NULL,
  13. `author_5` varchar(100) NOT NULL,
  14. `book_copies` int(11) NOT NULL,
  15. `book_pub` varchar(100) NOT NULL,
  16. `publisher_name` varchar(100) NOT NULL,
  17. `isbn` varchar(50) NOT NULL,
  18. `copyright_year` int(11) NOT NULL,
  19. `status` varchar(30) NOT NULL,
  20. `book_barcode` varchar(100) NOT NULL,
  21. `book_image` varchar(100) NOT NULL,
  22. `date_added` datetime NOT NULL,
  23. `remarks` varchar(100) NOT NULL,
  24. PRIMARY KEY (`book_id`)
Sample Codes - PHP This PHP source code is used for searching of the books. This is the syntax.
  1. <?php
  2. include('../admin/include/dbcon.php');
  3.  
  4. if(isset($_POST['search']))
  5. {
  6. $keyword = $_POST['keyword'];
  7. $status = $_POST['status'];
  8.  
  9. if ($status == '--All--') {
  10. $result= mysql_query("select * from book
  11. LEFT JOIN category ON book.category_id = category.category_id
  12. where (category.classname like '%$keyword%' or
  13. (book_barcode like '%$keyword%' or book_title like '%$keyword%'
  14. or author like '%$keyword%' or copyright_year like '%$keyword%'))
  15. order by book.book_id DESC ") or die (mysql_error());
  16. } elseif ($status == 'Title') {
  17. $result= mysql_query("select * from book
  18. LEFT JOIN category ON book.category_id = category.category_id
  19. where book_title like '%$keyword%'
  20. order by book.book_id DESC ") or die (mysql_error());
  21. } elseif ($status == 'Author') {
  22. $result= mysql_query("select * from book
  23. LEFT JOIN category ON book.category_id = category.category_id
  24. where author like '%$keyword%'
  25. order by book.book_id DESC ") or die (mysql_error());
  26. } elseif ($status == 'Category') {
  27. $result= mysql_query("select * from book
  28. LEFT JOIN category ON book.category_id = category.category_id
  29. where classname like '%$keyword%'
  30. order by book.book_id DESC ") or die (mysql_error());
  31. } elseif ($status == 'Copyright') {
  32. $result= mysql_query("select * from book
  33. LEFT JOIN category ON book.category_id = category.category_id
  34. where copyright_year like '%$keyword%'
  35. order by book.book_id DESC ") or die (mysql_error());
  36. } elseif ($status == 'Barcode') {
  37. $result= mysql_query("select * from book
  38. LEFT JOIN category ON book.category_id = category.category_id
  39. where book_barcode like '%$keyword%'
  40. order by book.book_id DESC ") or die (mysql_error());
  41. } else {
  42. $result= mysql_query("select * from book
  43. LEFT JOIN category ON book.category_id = category.category_id
  44. order by book.book_id DESC ") or die (mysql_error());
  45. }
  46. $return_count = mysql_num_rows($result);
  47. while ($row= mysql_fetch_array ($result) ){
  48. $book_id=$row['book_id'];
  49. $cat_id=$row['category_id'];
  50. ?>
Database Connection This is the script for our database connection.
  1. <?php
  2. mysql_select_db('opac_db',mysql_connect('localhost','root',''))or die(mysql_error());
  3. ?>
If the user searching the title of the book. This is the output. Result Share us your thoughts and comments below. Thank you so much for dropping by and reading this tutorial post. For more updates, don’t hesitate and feel free to visit this website more often and please share this with your friends or email me at [email protected]. Practice Coding. Thank you very much.

Comments

Submitted byjerry chuks (not verified)on Wed, 09/14/2016 - 17:51

The code is great but there is no category table. Hence, it can't search for book

Add new comment