setting a link on a while loop php
<pre><code>$query = mysql_query("SELECT * FROM mailtbl WHERE fromuser = '$adminsess' AND sent = '1'");

echo "To Subject Date View message";

while($fetch = mysql_fetch_assoc($query)) {

    $mid = $fetch['mid'];
    $to = $fetch['touser'];
    $subject2 = $fetch['subject'];
    $message2 = $fetch['message'];
    $date2 = $fetch['datesent'];
    $rand = $fetch['rand'];
    $view = "&lt;a href = 'messages.php?mode=".$sent."&amp;view=".$rand."'&gt;View message&lt;/a&gt;";

    echo "$to$subject2$date2$view";

}

echo "&lt;/table&gt;";

if (isset($view)) {

    $viewget = $_GET['view'];

    if ($viewget== $rand) {

        echo "hi";
        echo "$message2";

    } 
}
</code></pre>

<p>The <code>$view</code> there suppose to open the content of each message. The main problem is, if I have multiple values in the table, after clicking the link in each row in the table, the only link that is functioning is in the last row. The previous rows in the table with links doesn't show the content of the message (which is echo "hi" &amp; echo "$message2";).
What exactly is wrong with my code? thanks.</p>
