*

Recent

Author Topic: Adding users avatar and link to profile in comments  (Read 8530 times)

cravedgames

  • Newbie
  • *
  • Posts: 5
  • Force: +0/-0
Adding users avatar and link to profile in comments
« on: August 21, 2009, 11:01:21 PM »
Hello recently i have been styling the design for comments on my website and i was trying to add the users avatar and a link to their profile etc in their comments; Here is the code i am using at the moment for a link to their profile but it does not work :(

Code: [Select]
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['userid'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';

Please Help me find out the code needed to fix this. thanks in advance

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #1 on: August 22, 2009, 12:05:31 AM »
Try it this way instead

Code: [Select]

if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['commenter'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl ;
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';




The only thing I changed is the row that says

Code: [Select]

$useridl=$row['userid'];



to say

Code: [Select]

$useridl=$row['commenter'];



Let me know how that works. If it does not, let me know the URL where I can see it and look at what it's doing or not doing.

Adam LaCombe

  • Sr. Member
  • ****
  • Posts: 433
  • Force: +17/-0
    • My Blog
Re: Adding users avatar and link to profile in comments
« Reply #2 on: August 22, 2009, 12:12:17 AM »
I just took a look at you're site and I think all you're problem is, is the id.
try:
Code: [Select]
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));
while($row = $db->fetch_row($r)){
$date = date('d-m-Y', $row['date']);
$rra = $db->fetch_row($db->query(sprintf('SELECT username FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
$useridl=$row['userid'];
$urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl.'';
if ( $row['commenter'] == '0' ) {$commenter='Guest';} else {$commenter=$rra['username'];};
echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'</a>';

oh and for the avatars you could try:
Code: [Select]
if($comments_on == 1){
$r = $db->query(sprintf('SELECT * FROM dd_comments WHERE gameid=\'%u\' AND approved=\'1\' ORDER BY date DESC LIMIT 3', $ID));

while($row = $db->fetch_row($r)){
  $date = date('d-m-Y', $row['date']);
  $rra = $db->fetch_row($db->query(sprintf('SELECT username,avatarfile FROM dd_users WHERE userid=\'%u\'', $row['commenter'])));
  $useridl=$row['userid'];

if($row['avatarfile']){
  $useravatar=$row['avatarfile'];
}else{
$useravatar="default.jpg";
}

  $urlp = ''.$domain.'/index.php?action=showprofile&profile='.$useridl.'';

if ($row['commenter'] == 0){
$commenter='Guest';
}else{
$commenter=$rra['username'];};

echo '<b>Posted By:</b> <a href="'.$urlp.'">'.$commenter.'<br />
<img src="'.$domain.'/avatars/$useravatar" /></a>';

I think that should work..   ;)

cravedgames

  • Newbie
  • *
  • Posts: 5
  • Force: +0/-0
Re: Adding users avatar and link to profile in comments
« Reply #3 on: August 22, 2009, 12:50:02 AM »
Sorry, None of these codes seem to work :( i think its different when working with comments

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #4 on: August 22, 2009, 12:53:18 AM »
What's the URL so I can take a look at what it's doing?

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #5 on: August 22, 2009, 01:27:06 AM »
The code I just gave you above, I just tried it on an unmodified copy of the script on the page where you play the game and it worked on our server. If you have modified the page it might be something in the modifications that is interefering, or it might be server specific, or it could be something else. I would need to see it in action to know what the problem is. If you want to PM me your URL and FTP log on details I would be happy to take a look at it. I've been back and forth between the computer and some other things I have going on here, but I would try to get it done as soon as I could. Or I can make up a zip file of the one I did and you can try it.

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #6 on: August 22, 2009, 01:39:01 AM »
Here, when I posted above, my box was busy making a rather large zip file and I could not work on both at the same time. It got done faster than I though so I made a zip of the new play.php file. You can unzip it and drop it into /pages and see if it works like you want.

Back up your old one first!

Let me know if it works for you.
« Last Edit: August 22, 2009, 03:02:04 PM by Mr. Cashew »

cravedgames

  • Newbie
  • *
  • Posts: 5
  • Force: +0/-0
Re: Adding users avatar and link to profile in comments
« Reply #7 on: August 22, 2009, 12:08:42 PM »
Well using "Commenter" to get the user id seams to work but i still cant get the users avatar

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #8 on: August 22, 2009, 03:04:49 PM »
OK, now that we know that works I updated the file to include avatars. They only show if the member has them activated though, other wise it is left blank. 

The file has been updated, go ahead and redownload it and try it again. Let me know how it works.

cravedgames

  • Newbie
  • *
  • Posts: 5
  • Force: +0/-0
Re: Adding users avatar and link to profile in comments
« Reply #9 on: August 22, 2009, 07:11:51 PM »
Still doesnt seam to work :(

kurt

  • Developer
  • Hero Member
  • ******
  • Posts: 634
  • Force: +16/-1
Re: Adding users avatar and link to profile in comments
« Reply #10 on: August 22, 2009, 10:04:18 PM »
It doesn't work with the new file? It works on the demo as you can see here

http://demo.freearcadescript.net/play/29-Mario-Karte.html

If it still does not work on your server, I would have to look it over. Send me the FTP/cPanel log in details and I'll see what I can do.
« Last Edit: August 22, 2009, 10:59:23 PM by Mr. Cashew »

cravedgames

  • Newbie
  • *
  • Posts: 5
  • Force: +0/-0
Re: Adding users avatar and link to profile in comments
« Reply #11 on: August 23, 2009, 04:53:45 PM »
:(