php


Count occurrences across multiple arrays in PHP


I have multiple arrays returned in PHP that are generated from this query...
"SELECT * FROM `infringements` where (submittime >= '$datefromp' and submittime <= '$datetop') and stkey = '$stkey' ORDER BY submittime DESC";
and the output look like...
Array (
[ID] => 32
[STKEY] => 2087
[FIRST_NAME] => John
[SURNAME] => Smith
[GENDER] => F
[SCHOOL_YEAR] => 08
[ROLL_GROUP] => MILANG
[HOUSE] => UN
[hat] => 1
[jewellery] =>
[socks] =>
[makeup] =>
[hair] => 1
[shoes] =>
[icuniform] =>
[icpeuniform] =>
[INFRINGEMENT] =>
[USER] => vsmall
[SUBMITTIME] => 2017-05-15 14:26:42
)
There can be multiple arrays returned from the query and the users can submit multiple entries (via a form) each day. I would like to count the number of times that 'hat'=1 and/or 'socks'=1 etc per day. If they are empty then they can be skipped. What is the best way to do this?
I would like to display these counts back to the user.
Example:
15-05-17 - Hat x2
- Hair x1
16-6-17 - Hat x1
- Socks x1

Related Links

trying to get PHP to post string to a file
Can you change $_POST into something different
How to retrieve content of an external folder?
PHP multiple “SELECT FROM WHERE”'s [duplicate]
MySQL: detect if values exists in DB
How does PHP zend.script_encoding work?
PHP : page only updated in Firefox but not with Chrome nor Internet Explorer
CJuiDatePicker Always saves present day in database
How to read a CSV file into a 2d Array PHP
Forum Current Online users
Kohana Session Table
Can we embed our API code In Zoho CRM to integrate any other web application with Zoho CRM like Xero, DocuSign, Fedex and more others
'git' is not recognized as an internal or external command, operable program or batch file
Negative lookbehind on html comments with PHP for script extraction
PHP Zend Framework validators (String)
Laravel custom Admin-Filter with redirect-loop

Categories

HOME
office365
firebase
protocol-buffers
freeradius
facebook-messenger
yii
android-fragments
workflow
devexpress
mousemove
haproxy
initialization
google-webmaster-tools
qooxdoo
fedora
specifications
twitter-oauth
sap-fiori
buffer
sonata
google-tasks-api
string-formatting
cloudsim
deepfreeze
parceler
jitsi
activeadmin
tableview
acl
channel
ava
ipa
onchange
ibm-connections
unmarshalling
toad
osx-lion
sql-execution-plan
counting
textmate2
android-alarms
xll
sspi
android-n
selenide
right-click
grunt-contrib-watch
dagger
optionaldataexception
httphandler
permission-denied
type-inference
jshint
liteide
realstudio
sonarqube5.2
ol3-google-maps
non-linear-regression
node-apn
datediff
watir-webdriver
pecl
annotatorjs
wolfram-language
qpixmap
onepage-checkout
servicestack-bsd
linuxbrew
place
dsa
extend
domino-designer-eclipse
mobilefirst-server
console.log
directorysearcher
dos2unix
adhoc-polymorphism
password-recovery
window-resize
producer
senchatouch-2.4
forceclose
sqlbindparameter
xmi
usb-flash-drive
jmenubar
revmob
indesign-server
dynamic-rdlc-generation
thejit
delphi-prism
boost-foreach
radscheduler
fork-join
nosetests
azure-acs
kernel32
directshow.net
webresponse
ninject-interception
oracle-pro-c
iphone-sdk-3.1.3
html-generation

Resources

Encrypt Message