I am trying to display a list of persons. On clicking the list , more details on the person must be shown.
members.php: -a page to list all members
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h1>Our members are</h1>
<?php
include 'config.php';
session_start();
$sql = "SELECT name from users";
$result = $conn->query($sql);
echo '<table>';
if($result->num_rows > 0)
{
while($row = $result->fetch_assoc())
{
echo '<tr>';
$_SESSION['selection'] = $row['name'];
echo '<td><a href = "view.php">'.$row['name'].'</a></td>';
echo '</tr>';
}
}
echo '</table>';
$conn->close();
?>
</body>
view.php -the page to show more details:
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<?php
include 'config.php';
session_start();
$pkey = $_SESSION['selection'];
$new = "SELECT * FROM users where name = '$pkey'";
$display = $conn->query($new);
$result = $display->fetch_assoc();
echo 'Name:'.$result['name'];
echo 'Rollno:'.$result['rool_no'];
echo 'Description:'.$result['description'];
$conn->close();
?>
</body>
on using session , always the details of last person in the list is shown. How to display the corresonding details??