alohatofu Posted April 17, 2007 Share Posted April 17, 2007 Hello, I'm wondering if any mysql masters out there can help me with this. I'm trying to query the number of instances that the same value occur in a field in the last 90 days. Say that my field is called clli from table surv_item and the date let's call it $creation_date How would I do that? $query = "SELECT clli FROM surv_item"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result)) { extract($row); $clli[] = $clli; } $output = array_count_values($clli); that doesn't seem to work. I'm very new to mySQL. Thank you Link to comment https://forums.phpfreaks.com/topic/47369-count-array-help/ Share on other sites More sharing options...
sunilvadranapu Posted April 17, 2007 Share Posted April 17, 2007 you are using the same name for array variable and the table col. Just change the name of array and try. it is working for me, should work for you also. $query = "SELECT clli FROM surv_item"; $result = mysql_query($query); while ( $row = mysql_fetch_array($result)) { extract($row); $tmp[] = $clli; } $output = array_count_values($tmp); print_r($output); output: Array ( [1] => 3 [2] => 1 [3] => 1 [5] => 2 [10] => 1 ) I tested it for strings and numbers. -SunilKumar Link to comment https://forums.phpfreaks.com/topic/47369-count-array-help/#findComment-231117 Share on other sites More sharing options...
alohatofu Posted April 17, 2007 Author Share Posted April 17, 2007 Thanks! that did it Link to comment https://forums.phpfreaks.com/topic/47369-count-array-help/#findComment-231136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.