Changeset 144 for trollforge/lastmeasure


Ignore:
Timestamp:
11/30/05 18:23:59 (7 years ago)
Author:
sam
Message:
  • try to sort browsers and users by hits.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trollforge/lastmeasure/stats/index.php

    r142 r144  
    8282} 
    8383 
    84 function print_table($table) { 
     84function print_table($table, $count) { 
    8585    $id = dba_open($table, 'c', 'db4'); 
    8686    if(!$id) { 
     
    9393        return; 
    9494    } 
    95     for($l = 0; $key != false; $l++) { 
    96         $val = dba_fetch($key, $id); ?> 
     95    $items = array(); 
     96    while($key != false) { 
     97        $val = dba_fetch($key, $id); 
     98        $items[$key] = $val; 
     99        asort($items); 
     100        if(count($items) > $count) 
     101            array_pop($items); 
     102        $key = dba_nextkey($id); 
     103    } 
     104    $l = 0; 
     105    foreach($items as ($key => $val)) { ?> 
    97106        <tr style="background-color: <?php echo ($l % 2) ? '#cef' : '#ecf'; ?>"> 
    98107          <td><?php echo base64_decode($key); ?></td> 
    99108          <td><?php echo $val; ?></td> 
    100109        </tr><?php 
    101         $key = dba_nextkey($id); 
     110        $l++; 
    102111    } 
    103112    dba_close($id); 
     
    230239      <td>Count</td> 
    231240    </tr> 
    232     <?php print_table('../db/uagent.db'); ?> 
     241    <?php print_table('../db/uagent.db', 20); ?> 
    233242  </table> 
    234243 
     
    238247      <td>Count</td> 
    239248    </tr> 
    240     <?php print_table('../db/user.db'); ?> 
     249    <?php print_table('../db/user.db', 30); ?> 
    241250  </table> 
    242251 
Note: See TracChangeset for help on using the changeset viewer.