I am making a online social networking site, and have messging section, i want it to make it show only 1 messge from each user, So if you have a message from
for ex
Username "bob"
id "32"
and you have 5 messages from him
Then you have 20 messages from
username: heather
id: 63
then you have 12 messages from
username: tony
id: 21
You will only have 3 messages in your inbox 1 from each of these users. And each one displays 120 characters from the last message they sent.
How could i do this, then when they click on the message it will take them some where else to see there whole conversation?
this is the code i have for getting the information from the databse and echo it out.
$ID = $_COOKIE['idCookie'];
$query = mysql_query("SELECT * FROM `private_messages` WHERE to_id LIKE '$ID' AND To_Deleted LIKE '0' ORDER BY id DESC");
echo "<table width='100%' border='1'>";
$num = mysql_num_rows($query);
if ($num > 0){
while($row = mysql_fetch_assoc($query)){
$id = $row['id'];
$subject = $row['subject'];
$toid = $row['to_id'];
$read = $row['opened'];
$fromid = $row['from_id'];
$message = $row['message'];
$id = $row['id'];
$check_pic = "members/$fromid/image01.jpg";
$default_pic="members/0/default.png";
if(file_exists($check_pic)){
$user_pic ="<img src=\"$check_pic\" width=\"50\" heign='50'>";
}else{
$user_pic ="<img src=\"$default_pic\" width=\"50\" heign='50'/>";
}
if ($toid==$myid){
$query2 = mysql_query("SELECT * FROM `members` WHERE id LIKE '$fromid'");
while ($row = mysql_fetch_assoc($query2)){
$firstname = $row['firstname'];
$lastname = $row['lastname'];
if ($read =='1'){
$read = "Read";
}else{
$read="<a href='messages.php?Read=$id'>Mark as read</a>";
}
echo "<tr><td width='52'>$user_pic</td><td>From: <a href='/profile.php?id=$fromid'>$firstname $lastname</a> - <a href='messages.php?removeid=$id'><font color='red'>Delete</font></a> - $read
</br><hr>$message</td></tr>";
//}
}
}
}
}else{
echo "Your inbox is empty.";
}
echo "</table>";