Some JavaScript is required to show hidden fields. A helpful tip here, use associative arrays on this, it's not readable when you use numeric arrays (I am guessing the names below):
jsFiddle of below: https://jsfiddle.net/4sg5wjm3/
<form action="index3.php" method="get">
<!-- use mysqli_fetch_assoc here instead of mysqli_fetch_array -->
<?php while($row = mysqli_fetch_assoc($result2)): ?>
<div class="book-group">
<h3>Title of book : <?php echo $row['book_title'] ?></h3>
<div class="hide pad-bottom author">
<?php echo $row['author'] ?>
</div>
<div class="hide pad-bottom group">
<?php echo $row['book_group'] ?>
</div>
<div class="hide pad-bottom theme">
<?php echo $row['book_theme'];?>
</div>
<a href="#" class="reveal" data-reveal="author">Reveal Author</a>
<a href="#" class="reveal" data-reveal="theme">Reveal Theme</a>
<a href="#" class="reveal" data-reveal="group">Reveal Group</a>
<a href="#" class="reveal-next">NEXT</a>
</div>
<?php endwhile;?>
</form>
<!-- Need jQuery library -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script>
// Document ready
$(function(){
// When user clicks reveal button
$(".reveal").on('click', function(e) {
// Stop normal action of <a> tag
e.preventDefault();
// Find the parent div, then find the appropriate child div based on
// what the data- attribute is of the clicked button
$(this).parents('.book-group').find('.'+$(this).data('reveal')).fadeIn('fast');
});
});
</script>
<!-- Some styles to make the show/hide work -->
<style>
* {
font-family: Arial;
}
.hide {
display: none;
}
.pad-bottom {
padding-bottom: 1em;
}
a:link,
a:visited {
background-color: green;
float: left;
clear: both;
padding: 0.5em;
font-size: 1.2em;
border-radius: 3px;
text-decoration: none;
color: #FFF;
transition: background-color 0.5s;
margin: 0.2em;
}
.book-group {
display: flex;
flex-direction: row;
margin: 0.5em;
padding: 0.5em;
border-top: 1px solid #ccc;
}
</style>
Note, I have not done anything with the next button, it can have JS applied to it as well in the same manor as to show and hide the book-group
classes so only one book shows at a time.