i have created a php page in which i want that whenever i refresh the page it should shuffle and in that data i want that whenever i click on data it should redirect to a new page where that data should be displayed for this I have used Session to store it.
home.php
<?php
$con = new mysqli("localhost","root","","writersplanet");
$sql = "SELECT * FROM books ORDER BY RAND()";
$execute = mysqli_query($con,$sql);
while ($row = mysqli_fetch_assoc($execute)) {
$_SESSION['uploadcoverimg'] = $row['uploadcoverimg'];
$_SESSION['bookname'] =$row['bookname'];
$_SESSION['uname'] =$row['uname'];
$_SESSION['summary'] =$row['summary'];
$_SESSION['thoughts'] =$row['thoughts'];
$_SESSION['pdf'] = $row['pdf'];
$_SESSION['date'] = $row['date'];
echo "<div class='container' align='center'>
<a href='readbook.php'>
<div class='box'>
<div class='imgbox'>
<img src='upload/".$row['uploadcoverimg']."'>
</div>
<div class='content'>
<h3>".$row['bookname']." <i class='fas fa-chevron-circle-right'></i>".$row['uname']."</h3>
<p>".$row['summary']."</p>
</div>
</div>
</a>
<div class='outcome'>
<div class='heart'>
<i class='fas fa-heart'></i>
</div>
<div class='eye'>
<i class='fas fa-eye'></i>
</div>
<div class='ratings'>
<i class='fas fa-star-half-alt'></i>
</div>
</div>
<div class='scrollmenu1'>
<a href='#home' style='border-radius: 10px;margin-top: 10px; background-color: black;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Horror</a>
<a href='#news' style='border-radius: 10px;margin-top: 10px; width: 65px;height: 30px;box-sizing: border-box; background-color: #0a3da3;color: white;'>Sci-Fi</a>
<a href='#contact' style='border-radius: 10px;margin-top: 10px; background-color: #ff69b4;color: white; width: 65px;height: 30px;box-sizing: border-box;'>Love</a>
</div>
<div class='content1'>
<h2>Time</h2>
<p><br>
Writers Thoughts about this book:
".$row['thoughts']."
</p>
</div>
</div>";
}
?>
In my sql code I have used [id, uname, bookname, summary,thoughts,uploadcoverimg,pdf,date].
readbook.php
<img class='bookcover' src='Desert.jpg'>
<div class='heading'>
<h3><?php echo $_SESSION['bookname']; ?> <i class='fas fa-chevron-circle-right'></i><?php echo $_SESSION['uname'];?></h3>
</div>
<div class='container'>
<div class="half_star">
<i id='half_star' class='fas fa-star-half-alt'></i>
</div>
<div class="comment">
<i id='comment' class='fas fa-comments'></i>
</div>
<div class="like">
<i id='like' class='fas fa-thumbs-up'></i><br>
</div>
<div class="date">
<i id='date' class='fas fa-calendar-alt'></i><br>
<?php echo $_SESSION['date'];?>
</div>
<div class="share">
<i id='share' class='fas fa-share'></i>
</div>
<div class='scrollmenu1'>
<a class='horror' href='#home' color='white'>Horror</a>
<a class='sci-fi' href='#news'>Sci-Fi</a>
<a class='love' href='#contact'>Love</a>
</div>
</div>
<div class='summary'>
<h1>Summary of the Book</h1>
<p><?php echo $_SESSION['summary'];?></p>
</div>
<div class="thoughts2">
<h2 class="quotes_head">Thoughts of the Writer</h2>
<p><?php echo $_SESSION['thoughts'];?></p>
</div>
<div class="storyhead">
<h1>Let's start the story:</h1>
</div>
<div class="taskbar">
<button class="bookmark"><i id="bookmark" class="fas fa-bookmark"></i>Bookmark</button>
<button class="unlock"><i id="unlock" class="fas fa-unlock"></i>Unlock</button>
<button class="download">Download</button>
</div>
<div class="pages">
<a href="upload/<?php echo $_SESSION['pdf'];?>">click here!</a>
<iframe src="upload/<?php echo $_SESSION['pdf'];?>" width="1000px" height="500px"></iframe>
</div>
If anybody can help me then its a great thank you from my side because this is related to my career planning. Thank You