Trying to list icons for users...
Posted on 2009-04-27
I am trying to list 25 members along with each members latest chat message and photo.
Each member also has several icons listed in another table for their username.
I can get the message list and the user okay, but when it trys to grab all of their icons,
it only grabs the first icon listed for each user when they have an icon listed multple times.
Like some users have a dozen to be listed and others just have a few or none.
This is what I have so far...
$connection = mysql_connect ("localhost","myuser", "mypass") or die ("Cannot make the connection");
$db = mysql_select_db ("data",$connection) or die ("Cannot connect to database");
$sql_query1 = "SELECT user,message FROM chat ORDER BY numbss DESC LIMIT 25";
$result1 = mysql_query($sql_query1);
while ($row1 = mysql_fetch_assoc($result1))
$member1 = $row1['user'];
$message1 = $row1['message'];
$sql_query2 = "SELECT picimage FROM members WHERE user='$member1' ORDER BY id DESC LIMIT 1";
$result2 = mysql_query($sql_query2);
$row2 = mysql_fetch_array($result2);
$mypic1 = $row2['picimage'];
$sql_query3 = "SELECT user,anicon FROM icons WHERE user='$member1' ORDER BY id ASC";
$result3 = mysql_query($sql_query3);
$row3 = mysql_fetch_array($result3);
$member = $row3['user'];
$icon = $row3['anicon'];
$list .="$mypic1, $member1 said $message1<br>My icons: $icon<br><br>";
You see, it will only list one icon in the last part. How do I make it grab all the icons and list them all for each user?