Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4257
Latest: Alex998.
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43295
Total Topics: 7523
Most Online Today: 344
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 231
Total: 231

Author Topic: Add color functionality to the usernames of this query  (Read 5034 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Add color functionality to the usernames of this query
« on: September 19, 2014, 05:57:11 pm »
I would like to add color to the usernames of this function.

Code: [Select]
// Karma good top 10.
$members_result = db_query("
SELECT ID_MEMBER, realName, karmaGood
FROM {$db_prefix}members
WHERE karmaGood > 0
ORDER BY karmaGood DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_karma_good'] = array();
$max_karma_good = 1;
while ($row_members = mysql_fetch_assoc($members_result))
{
$context['top_karma_good'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_karma' => $row_members['karmaGood'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '">' . $row_members['realName'] . '</a>'
);

if ($max_karma_good < $row_members['karmaGood'])
$max_karma_good = $row_members['karmaGood'];
}
mysql_free_result($members_result);

foreach ($context['top_karma_good'] as $i => $poster)
$context['top_karma_good'][$i]['karma_percent'] = round(($poster['num_karma'] * 100) / $max_karma_good);

How would I do this?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Add color functionality to the usernames of this query
« Reply #1 on: September 19, 2014, 08:51:21 pm »
Updated code
Code: [Select]
// Karma good top 10.
$members_result = db_query("
SELECT  m.ID_MEMBER,  m.realName, m.karmaGood, mg.onlineColor 
FROM {$db_prefix}members as m
            LEFT JOIN {$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(m.ID_GROUP = 0, m.ID_POST_GROUP, m.ID_GROUP))
WHERE  m.karmaGood > 0
ORDER BY  m.karmaGood DESC
LIMIT 10", __FILE__, __LINE__);
$context['top_karma_good'] = array();
$max_karma_good = 1;
while ($row_members = mysql_fetch_assoc($members_result))
{
$context['top_karma_good'][] = array(
'name' => $row_members['realName'],
'id' => $row_members['ID_MEMBER'],
'num_karma' => $row_members['karmaGood'],
'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '"' . (!empty($row['onlineColor']) ? ' style="color: ' . $row['onlineColor'] . ';" ' :'' ) . '>' . $row_members['realName'] . '</a>'
);

if ($max_karma_good < $row_members['karmaGood'])
$max_karma_good = $row_members['karmaGood'];
}
mysql_free_result($members_result);

foreach ($context['top_karma_good'] as $i => $poster)
$context['top_karma_good'][$i]['karma_percent'] = round(($poster['num_karma'] * 100) / $max_karma_good);
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Add color functionality to the usernames of this query
« Reply #2 on: September 20, 2014, 12:54:39 am »
Surprisingly, that didn't do it either. I mean, it's not even throwing an error! It just displays the name without color.

However, changing it to this works

Code: [Select]
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '"' . (!empty($row_members['onlineColor']) ? ' style="color: ' . $row_members['onlineColor'] . ';" ' :'' ) . '>' . $row_members['realName'] . '</a>'
Thank you, again!

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16452
    • View Profile
Re: Add color functionality to the usernames of this query
« Reply #3 on: September 20, 2014, 12:55:48 am »
$row['onlineColor']  should be $row_members['onlineColor']
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: Add color functionality to the usernames of this query
« Reply #4 on: September 20, 2014, 12:57:03 am »
$row['onlineColor']  should be $row_members['onlineColor']

Got it :D

Thank you

 

Related Topics

  Subject / Started by Replies Last post
6 Replies
5378 Views
Last post January 23, 2007, 07:23:09 pm
by marcbkk
3 Replies
7216 Views
Last post August 19, 2008, 09:14:06 am
by gibbs
2 Replies
4319 Views
Last post August 26, 2010, 08:28:00 am
by guest6347
6 Replies
8248 Views
Last post April 12, 2011, 03:31:19 pm
by bruno
1 Replies
2718 Views
Last post August 13, 2011, 12:07:23 am
by SMFHacks

+- Recent Topics

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

is it possible to add support for odysee.com by fvlog19
March 21, 2024, 08:47:51 am

Request for admin notification by davejo
March 10, 2024, 01:31:59 am

I need help with torrent upload by Ineedsmfhelp
March 09, 2024, 10:01:13 pm

Powered by EzPortal