1 (edited by FredrikK 2007-01-16 12:30)

Topic: Statistics from the database

I have removed the info about "Newest user" and "Number of users online" from the bottom, but a big space is left!

How can i make this space disappear?

http://www.brunna.se/bilder/fraga2.png

Code in my viewforum:

// Collect some statistics from the database
$result = $db->query('SELECT COUNT(id)-1 FROM '.$db->prefix.'users') or error('Unable to fetch total user count', __FILE__, __LINE__, $db->error());
$stats['total_users'] = $db->result($result);

$result = $db->query('SELECT id, username FROM '.$db->prefix.'users ORDER BY registered DESC LIMIT 1') or error('Unable to fetch newest registered user', __FILE__, __LINE__, $db->error());
$stats['last_user'] = $db->fetch_assoc($result);

$result = $db->query('SELECT SUM(num_topics), SUM(num_posts) FROM '.$db->prefix.'forums') or error('Unable to fetch topic/post count', __FILE__, __LINE__, $db->error());
list($stats['total_topics'], $stats['total_posts']) = $db->fetch_row($result);

?>
<div id="brdstats" class="block">
    <h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
            </dl>
            <dl class="conl">
<?php

if ($pun_config['o_users_online'] == '1')
{
    // Fetch users online info and generate strings for output
    $num_guests = 0;
    $users = array();
    $result = $db->query('SELECT user_id, ident FROM '.$db->prefix.'online WHERE idle=0 ORDER BY ident', true) or error('Unable to fetch online list', __FILE__, __LINE__, $db->error());

    while ($pun_user_online = $db->fetch_assoc($result))
    {
        if ($pun_user_online['user_id'] > 1&&$pun_user_online['user_id'] != 1)
            $users[] = "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online['user_id'].'">'.pun_htmlspecialchars($pun_user_online['ident']).'</a>';
        else
            ++$num_guests;
    }

    $num_users = count($users);
    
    // users on line today 
    $date = getdate(time());
    $todaystamp = mktime(0,0,0, $date['mon'], $date['mday'], $date['year']);

$result = $db->query("SELECT username, id, last_visit from ".$db->prefix."users WHERE last_visit >= '".$todaystamp."' ORDER by last_visit DESC") or error("Impossible de retrouver la liste des utilisateurs en ligne aujourd'hui", __FILE__, __LINE__, $db->error());

    $users_today = array();
    while ($pun_user_online_today = $db->fetch_assoc($result))
        $users_today[] .=  "\n\t\t\t\t".'<dd><a href="profile.php?id='.$pun_user_online_today['id'].'" title="Dernière visite de '.$pun_user_online_today['username'].' : '.format_time($pun_user_online_today['last_visit']).'">'.$pun_user_online_today['username'].'</a>';
        
    $num_users_today = count($users_today);

    echo '</dl>'."\n";
    if ($num_users > 0)
        echo "\t\t\t".'<dl id="onlinelist" class= "clearb">'."\n\t\t\t\t".'<dt><strong>'.'Online just nu'.': </strong></dt>'."\t\t\t\t".implode(',</dd> ', $users).'</dd>'."\n\t\t\t".'</dl>'."\n";
    else
        echo "\t\t\t".'<div class="clearer"></div>'."\n";

// list users on line today
    echo "\t\t\t".'<dl id="onlinetodaylist">'."\n\t\t\t\t".'<dt><strong>'.'Online idag'.': </strong></dt>';
                
    if ($num_users_today > 0) 
        echo implode(',</dd> ', $users_today).'</dd>'."\n\t\t\t".'</dl>'."\n";
    else
        echo '<dd><em></em></dd>'."\n\t\t\t".'</dl>'."\n";

}
else
    echo "\t\t".'</dl>'."\n\t\t\t".'<div class="clearer"></div>'."\n";


?>
        </div>
    </div>
</div>
hej!

Re: Statistics from the database

Please.. hmm

hej!

Re: Statistics from the database

I solved it!

I changed this:

?>
<div id="brdstats" class="block">
    <h2><span><?php echo $lang_index['Board info'] ?></span></h2>
    <div class="box">
        <div class="inbox">
            <dl class="conr">
                <dt><strong><?php echo $lang_index['Board stats'] ?></strong></dt>
            </dl>
            <dl class="conl">
<?php

...to this:

?>
<div id="brdstats" class="block">
    <div class="box">
        <div class="inbox">
<?php
hej!