Try something like so (I got rid of the sessions and placed a get command for which row to provide)
CODE
<?php
include('database.php');
$result = mysql_query("SELECT * FROM autoalto_mail" );
$output = '';
while($row = mysql_fetch_array($result)){
$output += '<tr><td width="10%"></td>
<td ><img src="images/buldot.gif" alt="" height="6" width="6">
' . $row['from'] . '</td>
<td >
<a href="contractor_mail_action_contents.php?mail_id=' . $row['mail_id'] . '">';
}
mysql_close();
echo $output;
?>
<?
include('database.php');
$mailid1 = $_GET['mail_id'];
echo $mailid1;
$query1="SELECT * FROM autoalto_mail where mail_id='".$mailid1."'";
//echo $query1;
$result = mysql_query( $query1 );
//echo mysql_num_rows($result);
while($row = mysql_fetch_array($result)) {
echo $row['contents'];
}
mysql_close();
?>
THe only issue I believe you may run into with this is sql injection attempts so you will want to add some security (whatever type you like the most) to make sure they don't have mail_id set to something like
' or 1=1 drop table autoalto_mail ' (Which gets rid of the table called autoalto_mail, something that wouldn't be good).