• We just launched and are currently in beta. Join us as we build and grow the community.

Online Public Access Catalog For Library System

erectheum

Security Tools Creator
E Rep
0
0
0
Rep
0
E Vouches
0
0
0
Vouches
0
Posts
141
Likes
40
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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. CREATE

    TABLE

    [url=http://dev.mysql.com/doc/refman/%35%2E%31/en/control-flow-functions.html]IF

    NOT

    EXISTS

    [/url] `book`

    (
  5. `book_

    id`

    int

    (

    11

    )

    NOT

    NULL

    AUTO_INCREMENT

    ,
  6. `book_

    title`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  7. `category_

    id`

    int

    (

    50

    )

    NOT

    NULL

    ,
  8. `author`

    varchar

    (

    50

    )

    NOT

    NULL

    ,
  9. `author_

    2`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  10. `author_

    3`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  11. `author_

    4`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  12. `author_

    5`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  13. `book_

    copies`

    int

    (

    11

    )

    NOT

    NULL

    ,
  14. `book_

    pub`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  15. `publisher_

    name`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  16. `isbn`

    varchar

    (

    50

    )

    NOT

    NULL

    ,
  17. `copyright_

    year`

    int

    (

    11

    )

    NOT

    NULL

    ,
  18. `status`

    varchar

    (

    30

    )

    NOT

    NULL

    ,
  19. `book_

    barcode`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  20. `book_

    image`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  21. `date_

    added`

    datetime

    NOT

    NULL

    ,
  22. `remarks`

    varchar

    (

    100

    )

    NOT

    NULL

    ,
  23. PRIMARY KEY

    (

    `book_

    id`

    )
  24. )

    ENGINE

    =

    InnoDB

    DEFAULT

    CHARSET

    =

    latin1 AUTO_INCREMENT

    =

    8

    ;

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. if

    (

    isset

    (

    $_POST

    [

    'search'

    ]

    )

    )
  4. {
  5. $keyword

    =

    $_POST

    [

    'keyword'

    ]

    ;
  6. $status

    =

    $_POST

    [

    'status'

    ]

    ;

  7. if

    (

    $status

    ==

    '--All--'

    )

    {
  8. $result

    =

    mysql_query

    (

    "select * from book
  9. LEFT JOIN category ON book.category_id = category.category_id
  10. where (category.classname like '%$keyword

    %' o

    r
  11. (book_barcode like '%$keyword

    %' o

    r book_title like '%$keyword

    %'
  12. or author like '%$keyword

    %' o

    r copyright_year like '%$keyword

    %'))
  13. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  14. }

    elseif

    (

    $status

    ==

    'Title'

    )

    {
  15. $result

    =

    mysql_query

    (

    "select * from book
  16. LEFT JOIN category ON book.category_id = category.category_id
  17. where book_title like '%$keyword

    %'
  18. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  19. }

    elseif

    (

    $status

    ==

    'Author'

    )

    {
  20. $result

    =

    mysql_query

    (

    "select * from book
  21. LEFT JOIN category ON book.category_id = category.category_id
  22. where author like '%$keyword

    %'
  23. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  24. }

    elseif

    (

    $status

    ==

    'Category'

    )

    {
  25. $result

    =

    mysql_query

    (

    "select * from book
  26. LEFT JOIN category ON book.category_id = category.category_id
  27. where classname like '%$keyword

    %'
  28. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  29. }

    elseif

    (

    $status

    ==

    'Copyright'

    )

    {
  30. $result

    =

    mysql_query

    (

    "select * from book
  31. LEFT JOIN category ON book.category_id = category.category_id
  32. where copyright_year like '%$keyword

    %'
  33. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  34. }

    elseif

    (

    $status

    ==

    'Barcode'

    )

    {
  35. $result

    =

    mysql_query

    (

    "select * from book
  36. LEFT JOIN category ON book.category_id = category.category_id
  37. where book_barcode like '%$keyword

    %'
  38. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  39. }

    else

    {
  40. $result

    =

    mysql_query

    (

    "select * from book
  41. LEFT JOIN category ON book.category_id = category.category_id
  42. order by book.book_id DESC "

    )

    or die

    (

    mysql_error

    (

    )

    )

    ;
  43. }
  44. $return_count

    =

    mysql_num_rows

    (

    $result

    )

    ;
  45. while

    (

    $row

    =

    mysql_fetch_array

    (

    $result

    )

    )

    {
  46. $book_id

    =

    $row

    [

    'book_id'

    ]

    ;
  47. $cat_id

    =

    $row

    [

    'category_id'

    ]

    ;
  48. ?>

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.
search_na.jpg


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.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,158

323,328

323,337

Top