Я не тестировал этот код, но надеюсь, вы понимаете концепцию: -)
<?php
//Always use this preferbly at the start of the script
//when dealing with sessions in PHP
session_start();
//If data isset and contains anything
if (!empty($_GET['data'])) {
$data = unserialize($data); //Restore to the array
$id = $data['mid'];
//Set the actual session based on what user has clicked on
//If user has clicked on mid 1 , this will store $_SESSION['module1'] = value of stage
//If user has clicked on mid 2 , this will store $_SESSION['module2'] = value of stage
//etc
$_SESSION['module'.$id] = $data['stage'];
}
$sql = "select * from modulestb where teacherid=?";
$st = $pdo->prepare($sql);
$st->execute(array($_SESSION['logid']));
foreach ($st as $row) {
//Serialize the data you want to save into your session
//(Make the array a string that represents the array)
$data = serialize(array('stage'=>$row['stage'],
'mid' => $row['mid']));
echo "<a style='color:white;' href=report.php?data=$data>" . $row['name'] . " (Stage :" .
$row['stage'] . "</a>";
}