Advertisement:

Author Topic: Need help .. show avatar  (Read 1945 times)

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Need help .. show avatar
« on: December 09, 2018, 04:28:03 AM »
How to show Avatar by this code

Code: [Select]

<?

include('Settings.php');
$conn=mysql_connect($db_server,$db_user,$db_passwd) or die("ติดต่อเซิร์ฟเวอร์ไม่ได้");
$db=mysql_select_db($db_name,$conn) or die("ติดต่อฐานข้อมูลไม่ได้");
$charset = "SET character_set_results=UTF8";
mysql_query($charset) or die('Invalid query: ' . mysql_error());
$ID_BOARD = '1';
$sql = " SELECT * FROM smf_topics ";
$sql .= " INNER JOIN smf_messages ON smf_messages.id_msg = smf_topics.id_first_msg ";
$sql .= " WHERE smf_topics.id_board = '".$ID_BOARD."'   ORDER BY smf_topics.id_topic DESC LIMIT 3";
$res['result'] = mysql_query($sql);     

$cols=4;
$c=$cols;

$default_avatar = 'images/noavatar.png';
echo "

<table width='200px' align='center'>
<tr>
<td align='center' valign='top'>
        <table width="100%" cellpadding="2" oncontextmenu="return false;" style="margin-top:-3px;">
       <tr>
       <td align='center' width="200" valign="top"  onMouseOver="this.bgColor='#C5C7C4'">
";
  if (!empty($rs[$rs['id_member']]['avatar']['image'])){
echo "
', $rs[$rs['id_member']]['avatar']['image'],'';
                    }           
            else {
echo "
<img src="' . $default_avatar .'" alt="default_avatar" width="55" height="55"  class="img-circle" oncontextmenu="return false;" style="margin-top:0em;"/>     ";
                }
 
echo "

   </td></tr></table>
     ";
  }
}

?>



Online Pipke

  • Full Member
  • ***
  • Posts: 463
    • [NRNS]
Re: Need help .. show avatar
« Reply #1 on: December 09, 2018, 12:09:53 PM »
Maybe you can use this instead Avatars on Board and/or MessageIndex

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,162
  • Gender: Male
    • Kindred-999 on GitHub
Re: Need help .. show avatar
« Reply #2 on: December 09, 2018, 03:42:28 PM »
Why are you doing direct database queries?

Use the smf functions to protect the requests — or, even better, use the functions and variables already available in SSI.php
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #3 on: December 12, 2018, 04:45:08 AM »
thank you

in this code i want to know
what code to display avatar and name

please...  :'(

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Need help .. show avatar
« Reply #4 on: December 12, 2018, 05:08:15 AM »
What are you actually trying to do?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #5 on: December 12, 2018, 09:56:54 PM »
i just want to show who post by avatar and name
now i make it only message and topic

thank you  :-*

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,979
  • Gender: Male
    • Macedonian electronics forum
Re: Need help .. show avatar
« Reply #6 on: December 12, 2018, 10:26:42 PM »
Do you want to show the avatar of the last member that posted in a specific board, like this?

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #7 on: December 14, 2018, 01:29:11 AM »
Do you want to show the avatar of the last member that posted in a specific board, like this?



My code is show last 3 new post (Attachment 01)
but i want to show Avatar and name too  (Attachment 02)

sorry my english

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Need help .. show avatar
« Reply #8 on: December 14, 2018, 02:33:00 AM »
You want to show it where exactly?
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #9 on: December 14, 2018, 11:49:18 PM »
You want to show it where exactly?

In the first page (index page)

now



to like this


Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,162
  • Gender: Male
    • Kindred-999 on GitHub
Re: Need help .. show avatar
« Reply #10 on: December 17, 2018, 09:31:23 AM »
So, you want to edit your forum index page?

In that case, you most definitely should ***NOT*** be using that code that you posted.
1- it is insecure
2- Database queries should not generally be part of the template files
3- it is not necessary since almost all (if not all) the variables are already defined by the core forum


regarding your desire...   showing that little except is not enough. Show us the whole page...
What is your forum URL?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #11 on: December 21, 2018, 11:14:56 AM »
So, you want to edit your forum index page?

In that case, you most definitely should ***NOT*** be using that code that you posted.
1- it is insecure
2- Database queries should not generally be part of the template files
3- it is not necessary since almost all (if not all) the variables are already defined by the core forum


regarding your desire...   showing that little except is not enough. Show us the whole page...
What is your forum URL?

This code is works fine
Code: [Select]
<?

include('Settings.php');
$conn=mysql_connect($db_server,$db_user,$db_passwd) or die("ติดต่อเซิร์ฟเวอร์ไม่ได้");
$db=mysql_select_db($db_name,$conn) or die("ติดต่อฐานข้อมูลไม่ได้");
$charset = "SET character_set_results=UTF8";
mysql_query($charset) or die('Invalid query: ' . mysql_error());
$ID_BOARD = '1';
$sql = " SELECT * FROM smf_topics ";
$sql .= " INNER JOIN smf_messages ON smf_messages.id_msg = smf_topics.id_first_msg ";
$sql .= " WHERE smf_topics.id_board = '".$ID_BOARD."'   ORDER BY smf_topics.id_topic DESC LIMIT 3";
$res['result'] = mysql_query($sql);     

$cols=4;
$c=$cols;
echo "

<table width='200px' align='center'><tr> ";

while ($rs = mysql_fetch_array($res['result'])) {
  $c--;
         $sql_thumb = " SELECT * FROM smf_attachments WHERE id_msg = '".$rs['id_first_msg']."'  AND id_thumb !='0' ORDER BY id_attach ASC  LIMIT 1";
         $res['select_thumb'] = mysql_query($sql_thumb);     
         $rs_t = mysql_fetch_array($res['select_thumb']);
      echo "<td align='center' valign='top' >";
      ?>
      <table width="100%" cellpadding="2" oncontextmenu="return false;" style="margin-top:-3px;">
       <tr>
       <td align='center' width="200" valign="top" bgcolor="#FFFFFF" onMouseOver="this.bgColor='#C5C7C4'" onMouseOut ="this.bgColor = '#FFFFFF'"  style='
         padding:5px 5px 5px 5px;
height:100px;
overflow:hidden;
width120px;
    box-shadow: 0px 0px 1px #1a1a1a;
    border-radius:2px;
    margin-bottom:3px;
         '>
      <?
         if($rs_t['id_thumb']==''){
            echo "<a href='index.php?topic=".$rs['id_topic']."' target='_blank' style='
                  text-decoration:none;'  titlex='".mb_substr($rs['subject'],0,40,'UTF-8')."' class='tooltip'><img src='images/noimage.gif' border='0' style='
            padding:5px 5px 5px 5px;
height:116px;
width:116px;
overflow:hidden;
   
    border-radius:2px;
    margin-bottom:3px;
         ' ></a><br/>";
         }else{
            echo "<a href='index.php?topic=".$rs['id_topic']."' target='_blank'   titlex='".mb_substr($rs['subject'],0,40,'UTF-8')."' class='tooltip'><img src='index.php?action=dlattach;topic=".$rs['id_topic'].";attach=".$rs_t['id_thumb'].";image' style='
            padding:5px 5px 5px 5px;
height:116px;
width:116px;
overflow:hidden;
   
    border-radius:2px;
    margin-bottom:3px;
         ' ></a><br/>";   
         }
         echo "<a href='index.php?topic=".$rs['id_topic']."' target='_blank' style='
                  text-decoration:none;'><font style='
                  text-decoration:none;
  font-size: 80%;
                  color:#3b5998;'>".mb_substr($rs['subject'],0,12,'UTF-8')." ...</font><br><p titlex='".mb_substr($rs['subject'],0,40,'UTF-8')."' class='tooltip2'><img src='images/readmore.png' border='0'></p></a>";
   ?>
   </td></tr></table>
   <?
  echo "</td>";

  if ($c==0) {
    echo "</tr><tr>";
    $c=$cols;
  }
}
echo "</tr>\n</table>\n";
?>

i find the way to show avatar from this code

thank you

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Need help .. show avatar
« Reply #12 on: December 21, 2018, 12:05:56 PM »
And it will break when your host upgrades you to PHP 7.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,162
  • Gender: Male
    • Kindred-999 on GitHub
Re: Need help .. show avatar
« Reply #13 on: December 21, 2018, 12:17:53 PM »
and....

In that case, you most definitely should ***NOT*** be using that code that you posted.
1- it is insecure
2- Database queries should not generally be part of the template files
3- it is not necessary since almost all (if not all) the variables are already defined by the core forum
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline GigaWatt

  • The Smiley Guy
  • Support Specialist
  • SMF Hero
  • *
  • Posts: 1,979
  • Gender: Male
    • Macedonian electronics forum
Re: Need help .. show avatar
« Reply #14 on: December 21, 2018, 09:03:52 PM »
@ittiphol: Trust me, half baked solutions are never the way to go when you want to build something that's supposed to last.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #15 on: December 22, 2018, 10:14:48 AM »
So... it's not possible ?  :-\

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,162
  • Gender: Male
    • Kindred-999 on GitHub
Re: Need help .. show avatar
« Reply #16 on: December 22, 2018, 11:20:34 AM »
Of course it is..  you are just starting from the wrong point.
Use smf functions... there is no need to write separate database queries.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline ittiphol

  • Jr. Member
  • **
  • Posts: 202
Re: Need help .. show avatar
« Reply #17 on: December 22, 2018, 06:39:32 PM »
And the SSI function can do this?


Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 70,993
    • StoryBB/StoryBB on GitHub
Re: Need help .. show avatar
« Reply #18 on: December 22, 2018, 06:49:06 PM »
SSI can do a great many things, as well as calling the parts of SMF that do get avatars.

Thing is, I'm still no clearer in understanding where this should even show and which people it should show.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Study Force

  • SMF Hero
  • ******
  • Posts: 3,599
    • StudyForcePS on Facebook
    • @studyforceps on Twitter
Re: Need help .. show avatar
« Reply #19 on: December 23, 2018, 02:47:19 AM »
I think he wants the most recent posts, along with the title of thread, plus the avatar of the topic starter / (or last poster?) -- that last part I'm not sure. I don't think permissions are problem here, otherwise he'd mention it