OK Two tables, one with username and status ("new" or "old") another table (for PM's) with username,sendername and `read` ("yes" or "no"). I want to echo all usernames that are "old" from table1 and next to their names echo the sendername of all "old" messages from table2. Here's my code:
$query="SELECT username FROM `table1` WHERE status='old' order by username;
$result=mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
echo"<table border=\"1\" width=\"%50%\">";
$i=0;
$i1=0;
while ($i<$num){
$username=mysql_result($result,$i,"handle");
echo"<tr><td>$username,</td><td>";
$query1="SELECT sendername FROM `table2` WHERE username='$username' and `read`='0'";
$result1=mysql_query($query1) or die (mysql_error());
$num1=mysql_numrows($result1);
if($num1>0){
while ($i1<$num1){
$sendername=mysql_result($result1,$i1,"sendername");
echo"$sendername,";
++$i1;
}
}else{
echo" ";
}
echo"</td></tr>";
++$i;
}
echo"</table>";
The above code is not listing all the people who's status is "old" neither is it listing all the unread PM's. Any ideas?
Thanks in advance
$query="SELECT username FROM `table1` WHERE status='old' order by username;
$result=mysql_query($query) or die (mysql_error());
$num=mysql_numrows($result);
echo"<table border=\"1\" width=\"%50%\">";
$i=0;
$i1=0;
while ($i<$num){
$username=mysql_result($result,$i,"handle");
echo"<tr><td>$username,</td><td>";
$query1="SELECT sendername FROM `table2` WHERE username='$username' and `read`='0'";
$result1=mysql_query($query1) or die (mysql_error());
$num1=mysql_numrows($result1);
if($num1>0){
while ($i1<$num1){
$sendername=mysql_result($result1,$i1,"sendername");
echo"$sendername,";
++$i1;
}
}else{
echo" ";
}
echo"</td></tr>";
++$i;
}
echo"</table>";
The above code is not listing all the people who's status is "old" neither is it listing all the unread PM's. Any ideas?
Thanks in advance