<?php
include('../includes/functions.php');
session_start();
make_connection();
if(is_loggedin());
else
  redirect_to('index.php');
$user=get_user();
if(!$user)
 redirect_to('index.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <?php include('../includes/head.php');?>
  <title>Utopia- Edit book details</title>
  <link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" type="text/css" href="materialize/css/materialize.css">
  <link rel="stylesheet" type="text/css" href="css/home.css">
  <link rel="stylesheet" type="text/css" href="css/searchbook.css">
  <style type="text/css">
    .bookid{
      position: absolute;
      top: 5px;
      left:50%;
      text-decoration:underline;
      color: rgb(238, 110, 115);
    }
  </style>
</head>
<body>
  <div class="body row">
     <?php
    global $navactive;
    $navactive="editbookdetails";
    include('../includes/nav.php');
    ?>
  <div class="main">
    <div class="container">
      <header>
        <h3 class="center">Edit Book details</h3>
        <h5 id="youhave"></h5>
        <br>
      </header>
        <div class="booksdiv">
          <?php
          $my_books_result=get_my_books($user['regno']);
          $nobooks=0;

          while($my_books_result && $row=mysqli_fetch_assoc($my_books_result))
          {
            echo print_my_book($row);
            $nobooks++;
          }
          if($nobooks==1)
            $conte="You have $nobooks book.";
          else
            $conte="You have $nobooks books.";
          if($nobooks==0)
          {
            echo "<div class='nobook'>You have no books to edit..</div>";
            $conte="";
          }
          ?>
        </div>
    </div>
  </div>
</div>
<script src="js/jquery.js"></script>
<script src="materialize/js/materialize.js"></script>
<script>
$(".button-collapse").sideNav();
$('.button-collapse').sideNav({
      menuWidth: 300, // Default is 240
      edge: 'left', // Choose the horizontal origin
      closeOnClick: false // Closes side-nav on <a> clicks, useful for Angular/Meteor
    }
    );
</script>
<script>
document.getElementById('youhave').innerHTML="<?php echo $conte;?>";
</script>
</body>
</html>