I have a php page where list of people are displayed from the database. Now what I want to do is when I click a particular Person's data from the list it should redirect to another page where all the details of that person are present.Is it possible to do so?
I have two pages: list.php :- Here the list of people is displayed from database in small cards using bootstrap.The card includes some data like pid,pname. Details.php :- This page is where all the details of a person should display(e.g. pid,pname,pno,paddress,etc)
I tried using onclick function on that cards. It worked too but I have no idea how to get the data of that particular person clicked on the next page?
lists.php :- `
<?php
include 'config.php';
$sql = "SELECT p_id,p_name,p_adddate FROM sampletable";
$result=mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_assoc($result))
{
?>
<div class="card" onclick="window.location.href='details.php'">
<div class="card-body">
<?php echo <strong>".$row["p_id"].$row["p_name"]."</strong>
<span style='float:right;'>Date : ".$row["p_adddate"]."</span>";?>
</div>
</div>
details.php :-
<?php
include 'config.php';
$sql = "SELECT * FROM sampletable" WHERE p_id="HELP WHAT TO DO!!";
$result=mysqli_query($con,$sql);
if(mysqli_num_rows($result)>0)
{
while($row=mysqli_fetch_assoc($result))
{
?>
<div class="col">
ID: <?php echo $row['p_id']; ?>Name: <?php echo $row['p_name']; ?>
No: <?php echo $row['p_no']; ?>Address :<?php echo $row['p_add']; ?>
</div>
When I click a particular person on lists.php , I expect to display that particular person's all data on the details page. I tried storing id in session, but on next page the id stored in session is the id of the latest record in database.I cant get a specific id. Please help...Thanks in advance