Changeset 182 for trollforge/lastmeasure


Ignore:
Timestamp:
12/02/05 15:14:14 (7 years ago)
Author:
sam
Message:
  • factored table code
  • print total # of browsers and users
File:
1 edited

Legend:

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

    r181 r182  
    9494} 
    9595 
    96 function print_table($table, $count) { 
     96function toplist($title, $table, $count) { 
    9797    $id = dba_open($table, 'w', 'db4'); 
    9898    if(!$id) { 
     
    106106    } 
    107107    $items = array(); 
     108    $total = 0; 
    108109    while($key != false) { 
     110        $total++; 
    109111        $val = dba_fetch($key, $id); 
    110112        $items[$key] = $val; 
     
    114116        $key = dba_nextkey($id); 
    115117    } 
    116     $l = 0; 
     118    $l = 0; ?> 
     119    <table style="border: solid black 1px; margin: 5px;"> 
     120      <tr style="background-color: #8af;"> 
     121        <td><?php echo $title;?> (of <?php echo $total;?>)</td> 
     122        <td>Count</td> 
     123      </tr> <?php 
    117124    foreach($items as $key => $val) { ?> 
    118125        <tr style="background-color: <?php echo ($l % 2) ? '#cef' : '#ecf'; ?>"> 
     
    121128        </tr><?php 
    122129        $l++; 
    123     } 
     130    } ?> 
     131    </table><?php 
    124132    dba_close($id); 
    125133} 
     
    236244  </span> GNAA Last Measure Statistics </h1>  
    237245 
    238   <div style="float: left;"> 
    239     <table style="border: solid black 1px; margin: 5px;"> 
    240       <tr style="background-color: #8af;"> 
    241         <td>User</td> 
    242         <td>Count</td> 
    243       </tr> 
    244       <?php print_table($_SERVER['DOCUMENT_ROOT'].'/db/user.db', 30); ?> 
    245     </table> 
    246   </div> 
     246  <?php toplist('User', $_SERVER['DOCUMENT_ROOT'].'/db/user.db', 20); ?> 
    247247 
    248248  <table style="border: solid black 1px; margin: 5px;"> 
     
    258258  </table> 
    259259 
    260   <table style="border: solid black 1px; margin: 5px;"> 
    261     <tr style="background-color: #8af;"> 
    262       <td>Browser</td> 
    263       <td>Count</td> 
    264     </tr> 
    265     <?php print_table($_SERVER['DOCUMENT_ROOT'].'/db/uagent.db', 20); ?> 
    266   </table> 
     260  <?php toplist('Browser', $_SERVER['DOCUMENT_ROOT'].'/db/uagent.db', 20); ?> 
    267261 
    268262  <hr /> 
Note: See TracChangeset for help on using the changeset viewer.