knox203 Posted June 6, 2008 Share Posted June 6, 2008 Hey everyone, I have a query that grabs orders out of our database by a Monday through Sunday period. I'm wondering how can I get a count of all the orders per day without modifying my query? Can this be done with PHP? Here's my query: <?php $ic = " SELECT id, dts, driver, date, job, pay_period, round(base,2) as base_round FROM $databasename.$databasetable WHERE driver = '$username' AND left(dts, 15) = '$dts_select' AND pay_period = '".$_POST['pay_period']."'"; ?> Thanks! - Adam Link to comment https://forums.phpfreaks.com/topic/109036-group-and-count-results-per-day/ Share on other sites More sharing options...
discomatt Posted June 6, 2008 Share Posted June 6, 2008 I'm guessing you're selecting a whole week's data? You could include this in your mysql_fetch loop while ( $row = mysql_fetch_assoc( $result ) ) { # Incase E_ALL is on if ( !isset( $count[ $row['date'] ] ) ) $count[ $row['date'] ] = 0; $count[ $row['date'] ]++; } print_r($count) There's probably an easier way, though. Link to comment https://forums.phpfreaks.com/topic/109036-group-and-count-results-per-day/#findComment-559360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.