Here's the scenario. In my webpage I have 14 buttons , each one of them having unique id which is similar to the corresponding book_id stored in the database.In order to show the contents of the book I have to redirect it to next page (bookpage.php) by passing the book_id . It's working fine till here. In the bookpage.php when I try to access the id through the URL it's not working. If I set the type to int it stores the value 0 , if I don't set it to int then I get an empty page.
Here's the code of Genre.php (The first webpage)
<button class='read' id = $book_id type='submit'><h4>Free Preview </h4></button> 
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        $(document).ready(function() {
        $('.read').click(function() {
            const bookId = this.id;
            window.location.href = 'bookpage.php?id=' + bookId;
        }); 
    });
  </script>
Now here's the code snippet of bookpage.php (The second webpage)
 <?php
    $bookId =$_GET['id'];
    $select = "Select * from books where Book_ID = $bookId";
    $result = mysqli_query($con,$select);
    $book = $result->fetch_assoc();
    $title = $book['Title'];
For example take the URL as : http://localhost/Biblion/bookpage.php?id=A21
In this case I just get a blank page. If I write it as $bookId =(int) $_GET['id] and print the variable I get the value 0.
Thanks a lot!
 
    