here is my code for message i want to show message with avatar .i'm unable to create it
any one help me for displaying message with avatar

my message system

<?php

require "database.php";
$userfinal=$_SESSION['MM_Username'];

// get the messages from the table.
$get_messages = mysql_query("SELECT message_id FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$get_messages2 = mysql_query("SELECT * FROM messages WHERE to_user='$userfinal' ORDER BY message_id DESC") or die(mysql_error());
$num_messages = mysql_num_rows($get_messages);

// display each message title, with a link to their content

for($count = 1; $count <= $num_messages; $count++)
{

    $row = mysql_fetch_array($get_messages2);
    //if the message is not read, show "(new)" after the title, else, just show the title.
 
if($row['message_read'] == 0)
{  
echo'<hr color="#007FAA">';
   echo   $row['from_user'].  '<br>';
   echo  $row['message_contents'] . '</a><br>
	<br>';
	
}else{
echo '<a href="read_message.php?messageid=' . $row['message_id'] . '">' . $row['message_title'] . '</a><br>';
}}
echo '<form name="backfrm" method="post" action="inbox.php">';
echo '<input type="submit" value="Back to Home">';
echo '</form>';

?>

using this code for my avatar display

<?php
require("connect.php");
 
$username=$_SESSION['MM_Username'];
$query=mysql_query("SELECT *FROM members WHERE username='$username'");
if(mysql_num_rows($query)==0)
        die("User not found!!!!");
else
{
        $row=mysql_fetch_assoc($query);
        $location=$row['avatar'];
        echo "<img src='$location' width='100' height='100'>";
		
} 
 
?>

can i ask one question :

you want to display the to_user avatar or from_user avatar here ????

pass the appropriate username in your query while printing avatar.

i want to show avatar from user who has send message to me.

can i ask one question :

you want to display the to_user avatar or from_user avatar here ????

pass the appropriate username in your query while printing avatar.

so in this below line you have to pass sender user name not the loggged user name(session).

$query=mysql_query("SELECT *FROM members WHERE username='$username'");

please help me for display avatar to my message page. my view.php page is working but i want to display avatar to my message.php page

username
avatar
message contents

can you help me for edit message.php page


so in this below line you have to pass sender user name not the loggged user name(session).

$query=mysql_query("SELECT *FROM members WHERE username='$username'");

what is the error you are getting here ???

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.