Code: Select all
$display= mysql_query("SELECT * FROM `comments` WHERE `CommentTO`=".$profileid."");
print("<a href=\"viewprofile?userid=".$profileid."&CommentID=index\">");
$row = mysql_fetch_array($display);
if(!empty($row['CommentTO'])){
$output.='<img src="http://4boredom.com/com?commentid='.$row['CommentID'].'" />';
print($output);
} else {
print("No Comments");
}
print("</a>");
Actually, you're fairly close, considering your comment.
At the end of the first line, you don't need the ."" after $profileid.
Are you sure you want $output to be an
image tag? Does the URL reference a location where there is an image file?
Beyond that, can you be sure that there will be only one record per profile?
Assuming from your comment that you are a rank beginner, you've done pretty well. You might do well to learn some of the terminology, though. What you referred to as "vars" are
field names, also called
column names. When listing the structure of a table (the column names), the convention is to list them vertically and show their data types, like:
CommentID INT(11)
CommentLOC VARCHAR(20)
CommentTO VARCHAR(30)
CommentFROM VARCHAR(30)
CommentMESSAGE VARCHAR(240)
CommentDATE DATE
That's not very important in this case, but it's good to form the habit of doing it the way others expect it, for future use.