Jump to content

mattia

Members
  • Posts

    267
  • Joined

  • Last visited

Posts posted by mattia

  1. ok i solved with this code

    <?php           
    
                               $somar = mysql_query("SELECT SUM(landingrate) as landingrate FROM `phpvms_pireps` WHERE pilotid=$userinfo->pilotid");
                               $total = mysql_fetch_array($somar);
                               $v_total = $total['landingrate'];
                               $linha = mysql_query("SELECT *  FROM `phpvms_pireps` WHERE pilotid=$userinfo->pilotid");
                               $taxa = mysql_num_rows($linha);
                               $v_taxa = $taxa;                       
    
                               $media = $v_total/$v_taxa;
                               $v_media = number_format($media, 0, '.', '');
                           ?>
                     <?php echo $v_media." ft/min"; ?>

    but you can have a table to put our best 10?

    thanks for the help

  2. hi jeff

    tried your code in profile_main.tpl but does not work

    this is my error

    Fatal error: Call to undefined method TouchdownStatsData::pilot_average() in /var/www/virtual/italianivolanti.it/htdocs/iv/core/templates/profile_main.tpl on line 308

  3. <?php $pirep->pilotid.' '.$pirep->firstname.' '.$pirep->lastname?>
    

    or

    <th>'.$pirep->pilotid.' '.$pirep->firstname.' '.$pirep->lastname.'</th>

    hi jeff

    thanks for help but dont work i try

    <?php
    $query="SELECT * FROM phpvms_11pireps
    WHERE flighttime_stamp > '00:00:00'
    ORDER BY flighttime_stamp 	 DESC LIMIT 15";
    $list=DB::get_results($query);
    foreach ($list as $pirep)
    {
    	echo '<tr><th>
    
    '.$pirep->pilotid.' '.$pirep->firstname.' '.$pirep->lastname.'
    
    </th>
    <th>'.$pirep->flightnum.'</th>
    <th>'.$pirep->flighttime_stamp 	.'</th>
    <th>'.$pirep->source.'</th>
    </tr>';
    
    }
    echo '</table>'
    ?>
    

    appears only pilot id

  4. hi all,

    I created this code to see the longest flight

    
    <h4>TEST</h4>
    <table width="100%" border="1" align="center">
    <tr bgcolor=blue>
    <th><b><font color=black>pilot</th></b>
    <th><b><font color=black>flight</th><b/b>
    <th><b><font color=black>time</th></b>
    <th><b><font color=black>cliente</th></b>
    </tr>
    
    <?php
    $query="SELECT * FROM phpvms_11pireps
    WHERE flighttime_stamp > '00:00:00'
    ORDER BY flighttime_stamp DESC LIMIT 15";
    $list=DB::get_results($query);
    foreach ($list as $pirep)
    {
    
    echo '<tr><th>'.$pirep->pilotid.'</th>
    <th>'.$pirep->flightnum.'</th>
    <th>'.$pirep->flighttime_stamp 	.'</th>
    <th>'.$pirep->source.'</th>
    </tr>';
    
    }
    echo '</table>'
    ?>
    
    

    works, but how can I take from the pilot ID his name and surname of the pilot??

    thanks in advance to all :)

  5. How about something like this Mark;

    Add to TouchdownstataData.class.php

      function get_averages($howmany) {
    
           $avg = array();
    
           $pilots = PilotData::findPilots(array('retired' => '0'));
    
           foreach($pilots as $pilot)
               {
                   $query = "SELECT AVG(landingrate) as average, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'";
                   $result = DB::get_row($query);
                   if($result->pilotid != '')
                   {$avg[] = $result;}
               }
    
           rsort($avg);
    
           return array_slice($avg, '0', $howmany);
       }
    

    Add to TouchdownStats.php

       function averages($howmany)   {
           $this->set('stats', TouchdownStatsData::get_averages($howmany));
           $this->show('touchdownstats/touchdownstats_averages.tpl');
       }
    

    Add a new template in core/templates/touchdownstats called touchdownstats_averages.tpl

    <h3>Best Average Landing Rate</h3>
    <?php
    if($stats)
    {
       echo '<table>';
       echo '<tr>';
       echo '<th>Landing Rate</th>';
       echo '<th>Pilot</th>';
       echo '</tr>';
           foreach($stats as $stat)
           {
               $pilot = PilotData::getPilotData($stat->pilotid);
               echo '<tr>';
               echo '<td>'.round($stat->average, 1).'</td>';
               echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
               echo '</tr>';
           }
       echo '</table>';
    }
    else
    {
       echo 'No Stats Available';
    }
    ?>
    

    Then call it by url and pass how many records you want as the last element

    http://www.yoursite.com/index.php/touchdownstats/averages/10

    or within another template

    <?php MainController::run('touchdownstats', 'averages', '10'); ?>

    Hi Dave!

    does not work for me, no result, only exits "No Stats Available"

    http://s3.imagestime.com/out.php/i631825_Immagine.png

    thanks and happy new year

×
×
  • Create New...