how to view messages with profile image .anyone help me


my profile view page

<?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'>";
		
}
 
?>

My message page

<?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>';

?>

Recommended Answers

All 5 Replies

You want to show image on profile page or message page?
You have written image code.What is the problem?
echo "<img src='$location' width='100' height='100'>";
For src you have to give either relative path to image or absolute path.

Member Avatar for diafol

THis makes little sense to me:

echo'<hr color="#007FAA">';
   echo ''   . '' . $row['from_user'] . '<br>';
	echo ''  . '' . $row['message_contents'] . '</a><br><br>';

Why are you concatenating zero-length strings? Are you using XHTMl or HTML? If the former, your tags are about 10 years out of date.

this code is active in my view page but nothing happen when i put this code in inbox.php
error in image display.how to set path

You want to show image on profile page or message page?
You have written image code.What is the problem?
echo "<img src='$location' width='100' height='100'>";
For src you have to give either relative path to image or absolute path.

if $location = mypic.jpg
and you have store that image under some directory.
e.g. under 'project' folder you have saved image in upload/avatar/mypic.jpg
Then <img src="<?='upload/avatar/'.$location?>"> // if your page is beside upload folder. This is relative path.

Member Avatar for diafol

Use full php tags:

<img src="<?php echo "upload/avatar/$location";?>" />
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.