Jump to content


Adding certain values in an array

  • Please log in to reply
No replies to this topic

#1 bobbippon

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 17 November 2005 - 01:18 AM

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?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users