Jump to content

Newbie question here.


powlouk

Recommended Posts

I have this code here that ive just added to my forum and its all working perfectly except the layout isnt quite how i would like it. Currently the results are displayed in a single line as [b]'user' 'post count', 'user' 'post count',[/b]. I would prefer the reults to be displayed in a list like this..

[b]'user' 'post count'
'user' 'post count'[/b]

Hope you can help guys.  ;)


[quote]if ($board_config['top_posters'])
{
$top_posters = $board_config['top_posters'];

$sql = "SELECT username, user_id, user_level, user_posts
        FROM " . USERS_TABLE . "
        WHERE user_id <> " . ANONYMOUS . "
        ORDER BY user_posts DESC LIMIT $top_posters";
if( !($result = $db->sql_query($sql)) )
{
        message_die(GENERAL_ERROR, 'Could not Query Top Posting Users', '', __LINE__, __FILE__, $sql);
}

$user_count = $db->sql_numrows($result);
$user_data = $db->sql_fetchrowset($result);

$firstcount = $user_data[0]['user_posts'];
$total_posts = get_db_stat('postcount');
$total_top_posters = 0;
$top_posters_userlist = '';
$seperator = ', ';

for ($i = 0; $i < $user_count; $i++)
{
if ($user_data[$i]['user_level'] == ADMIN)
{
$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor2'] .'">'. $user_data[$i]['username'] .'</span></b>';
}
else if ($user_data[$i]['user_level'] == MOD)
{
$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor3'] .'">'. $user_data[$i]['username'] .'</span></b>';
}
else
{
$user_data[$i]['username'] = '<b><span style="color:#'. $theme['fontcolor1'] .'">'. $user_data[$i]['username'] .'</span></b>';
}

$top_posters_userlist .= (( ($top_posters_userlist) && ($user_data[$i]['user_id']) ) ? $seperator : '') .'<a alt="'. $alt .'" title="'. $alt .'" href="profile.'. $phpEx .'?mode=viewprofile&amp;u='. $user_data[$i]['user_id'] .'" class="copyright">'. $user_data[$i]['username'] .'</a>('. $user_data[$i]['user_posts'] .')';

$total_top_posters++;
}
}[/quote]
Link to comment
https://forums.phpfreaks.com/topic/26524-newbie-question-here/
Share on other sites

Its ok, ive sussed it, thanks for putting me on the right track. not sure if ive done it the correct way but it woeks so im happy.
[quote]$top_posters_userlist .= (( ($top_posters_userlist) && ($user_data[$i]['user_id']) ) ? $seperator : '') .'<p><a alt="'. $alt .'" title="'. $alt .'" href="profile.'. $phpEx .'?mode=viewprofile&amp;u='. $user_data[$i]['user_id'] .'" class="genmed">'. $user_data[$i]['username'] .'</a>&nbsp;('. $user_data[$i]['user_posts'] .')</p>';[/quote]
Link to comment
https://forums.phpfreaks.com/topic/26524-newbie-question-here/#findComment-121374
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.