Jump to content
Updating IPB tonight Read more... ×


This topic is now archived and is closed to further replies.


Adding certain values in an array

Recommended Posts

I manage a website for a flight simulator virtual airline. The members, or pilots, enter flight reports through our website that go into a MySQL database. I would like a way to run a report to see who has logged the most hours during a particular time frame. My PHP/MySQL skills are somewhat limited. Everything I know I owe to PHP/MySQL for Dummies.


So far this is what I have:


$start_date = $HTTP_POST_VARS['start_date'];
$end_date = $HTTP_POST_VARS['end_date'];

$sql = "SELECT pid, fhours FROM `pireps` WHERE status='1' AND date > '$start_date' AND date < 

'$end_date' ORDER BY fhours DESC";

while ( list($pid, $fhours) =  mysql_fetch_array($sth)) {

    $count ++;

if ($count < 1) {
echo "No logged flights found between $start_date and $end_date";
} else {



I did leave out the section that would display the results in a table for now. Where I need help is with the array. The pilots will each have multiple flight reports entered into the database. I need a way to add up all their hours, and then display the pilot who has the most logged hours during the time period that was searched. Or just display a list with the top pilot first and go down from there. Any suggestions?

Share this post

Link to post
Share on other sites


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.