<?PHP 
define('DB_HOST', 'localhost');
define('DB_USER', 'admin_opac');
define('DB_PASS', 'admin_opac');
define('DB_NAME', 'admin_opac');
	$connection = mysql_connect(DB_HOST,DB_USER,DB_PASS) or die(mysql_error());
	mysql_select_db(DB_NAME) or die(mysql_error());
?>
	<?php 
	class Mysql {
	private $conn;
	function __construct() {
		$this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
					  die('There was a problem connecting to the database.');		  
	}
	function book_query() {
		$query = "SELECT * FROM books";
	}	
	}
		function all_books_display() {
			$mysql = New Mysql();
			$books = $mysql->book_query();
			WHILE($books_tot = mysql_fetch_object($books)){
			echo $books_tot->title;
			}
		}
	?>
<?php
	function addtostat($id){
			mysql_query("INSERT INTO book_stat (book_id) VALUES('$id')") or die(mysql_query());
	}
?>
	<?php 
	function list_books() {
		$all_books = mysql_query("SELECT * FROM books") or die(mysql_error());
	
	?>
		<div class="list_books">
			<ul>
			<?php WHILE($list_books = mysql_fetch_array($all_books)){ ?>
				<li class="<?php echo $list_books['book_id']; ?>"><?php echo $list_books['title']; ?></li>
			<?php } ?>
			</ul>
		</div>
	
	<?php } ?>
	
	<?php 
	function books_count() {
		$all_books = mysql_query("SELECT * FROM books") or die(mysql_error());
		$count_book = 0;
	?>
			<?php WHILE($list_books = mysql_fetch_array($all_books)){ 
			$count_book++;
			}
			echo $count_book;
			?>
			
	<?php } ?>
	
		<?php 
	function books_flipiniana() {
		$all_books = mysql_query("SELECT * FROM books WHERE section='filipiniana'") or die(mysql_error());
	$count_book = 0;
	?>
			<?php WHILE($list_books = mysql_fetch_array($all_books)){ 
			$count_book++;

			}
			echo $count_book;
			?>
			
	<?php } ?>
	
			<?php 
	function books_mag() {
		$all_books = mysql_query("SELECT * FROM books WHERE section='magazine'") or die(mysql_error());
	$count_book = 0;
	?>
			<?php WHILE($list_books = mysql_fetch_array($all_books)){ 
			$count_book++;

			}
			echo $count_book;
			?>
			
	<?php } ?>
	
	<?php 
	function books_circ() {
		$all_books = mysql_query("SELECT * FROM books WHERE section='circulation'") or die(mysql_error());
	$count_book = 0;
	
			 WHILE($list_books = mysql_fetch_array($all_books)){ 
			$count_book++;

			}
			echo $count_book;		
	} ?>
	
	<?php
	function books_thes() {
		$all_books = mysql_query("SELECT * FROM books WHERE section='thesis'") or die(mysql_error());
		$count_book = 0;
		WHILE($list_books = mysql_fetch_array($all_books)){ 
		$count_book++;
		}
		echo $count_book;	
		}
		
	?>
	<?php 
		function storeName() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['title'];
		}
	?>
		<?php 
		function storeSubName() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['sub_title'];
		}
	?>
		<?php 
		function copyright() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['copyright'];
		}
	?>
		<?php 
		function email() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['EmailAddress'];
		}
	?>
	<?php 
		function phoneNumber() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['phoneNumber'];
		}
	?>
	
		<?php 
		function address() {
			$storeName = mysql_query("SELECT * FROM config") or die(mysql_error());
			$storeHeaderName = mysql_fetch_array($storeName);
			return $storeHeaderName['address'];
		}
	?>