MySQL/Arrays/Performing Calcs
Posted: Fri Jun 13, 2008 10:51 am
Thus far I've been able to avoid having to do this as most of my involvement with MySQL has been dumps of desired data.
In this case however, I need to calculate and return results from a SQL query, and I'm not sure how to work with the array to get the data I want.
SQL query and fetch;
Now that I have the data in $data, how do I perform calculations on the entire array? Say I wanted to add up the column 'time' for every row as an example.
Thanks for any help
In this case however, I need to calculate and return results from a SQL query, and I'm not sure how to work with the array to get the data I want.
SQL query and fetch;
Code: Select all
<?php
$result = mysql_query("SELECT In_Out, Date, Time, Number, Duration, Line, Station, identifier
FROM $table
WHERE date>='$start_date' AND date<='$end_date' AND time>='$hours1' AND time<='$hours2' AND Line=6
");
$data = mysql_fetch_array($result)
?>
Thanks for any help