Jump to content

Adding certain values in an array


bobbippon

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:

<?
include("../../include.php");

$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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • Create New...

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.