Jump to content

Recommended Posts

Posted

Wrote a script to get VA total flights current month

This for StatsData.class

/**

* Return the number of flights current month

*

* @return int Total number of flights

*

*/

public static function Totalflightscurrentmonth($airline_code='')

{

$key = 'total_flights_month';

if($airline_code != '')

{

$key .= '_'.$airline_code;

}

$total = CodonCache::read($key);

if($total === false)

{

$sql = 'SELECT COUNT(*) AS `total`

FROM '.TABLE_PREFIX.'pireps p

WHERE month(p.submitdate) = month(now())

AND year(p.submitdate) = year(now())';

$result = DB::get_row($sql);

if(!$result)

{

$total = 0;

}

else

{

$total = $result->total;

}

CodonCache::write($key, $total, '15minute');

}

return $total;

}

and this for Index.tpl from vStatsCenter

<?php echo StatsData::Totalflightscurrentmonth(); ?>

And working fine :) :) :)

but want to show Total Flights This Month for each pilot, in pilots_list.tpl

<?php echo StatsData::Totalflightscurrentmonth()($pilot->pilotid) ?>

but had an error

Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/surair/public_html/phpvms/core/templates/pilots_list.tpl on line 72

Any help would be appreciated

Best regards.

  • Members
Posted

You have an excess character or you havent closed the line with ; in line 72 of your pilots_list.tpl

and also the proper way to use a function is

FunctionClass::FunctionName(any nececary info like pilot id);

in your case it should be

<?php echo StatsData::Totalflightscurrentmonth($pilot->pilotid); ?>

every line in php except some spesial cases HAVE to end with ;

  • Members
Posted

with the query that you have provided you ask for statistics per months to be honest i dont undertand what exacly are you trying to achieve if you can please describe it

Posted

You need to add the pilot id into the sql, otherwise it is doing nothing with the pilot id. The where clause has to be ammended. I am working on it, not found the code that works yet.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...