Hi guys, creating a "who's online" module for my project where I can view the user's profile when online. I'm able to view whose online now, but no matter who I click, it would only display the last person's information.
From my understanding, this line of code needs some editting which I'm not really sure about doing it.
echo '<a href ="#" onclick="document.formname.submit(); return false;">'
.$row2['uname'].'<input name="friendName" type="hidden" value="'.$row2["uname"].'" /></a> ,';
I spent a whole afternoon trying to find an appropriate solution but could not solve my problem still. I managed to post information from my main page to the second page but however it only obtains the last information when I retrieve it on the second page.
How do I get the correct information I want ? My codes are below
<?PHP
//session_start();
include ('conn.php');
include ('time.php');
echo '<br>
<form name="formname" method="POST" action="friendProfile.php">';
$query5 ="select uname from online where online='1'";
$result5 = mysql_query($query5) or die('Query failed: ' . mysql_error());
if (!$result5) {
echo 'Could not run query: ' . mysql_error();
exit;
}//echo 'users online....';
$num = mysql_numrows ($result5);
if($num ==1){
while ($row2 = mysql_fetch_assoc($result5)) {
echo '<a href ="#" onclick="document.formname.submit(); return false;">'.$row2['uname'].'<input name="friendName" type="hidden" value="'.$row2["uname"].'" /></a> ,';
}echo ' is online.';
}else if($num ==0){
echo 'Nobody is online.';
}else{
while ($row2 = mysql_fetch_assoc($result5)) {
echo '<a href ="#" onclick="document.formname.submit(); return false;">'.$row2['uname'].'<input name="friendName" type="hidden" value="'.$row2["uname"].'" /></a> ,';
}echo ' are online.';}
echo '</form>';
?>