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

Getting All Unique Post Meta Values of a Meta Key
Php parameterized function call from html [duplicate]
How to extract information between xml tag
What is the rule to create a polymorphic field name in Laravel?
I got error ‘403 Forbidden Access is forbidden to the requested page’
Capture output arguments as separate from PHP exec()
Remove the profile.php?name=Username from url and replace with profile/Username [duplicate]
Is it possible to make different htaccess user authentication on two different files?
How to use FormType and ManyToMany relationships with FOSRestBuendle
Laravel email template urls not working in gmail
PayPal Sandbox returns Invalid - IPN verification
MySQL efficient way to select rows from table 1 where join does not exist
How to convert “1d2h3m” to array(“day” => 1, ”hour” => 2,“minutes”=>3)?
Exclude a category id from category collection in magento
Select info from a record that has max date and specific foreign key
How do I write the code without “strtotime”

Categories

HOME
php
jboss
nam
entity-framework
gaming
plpgsql
risk-management
visual-studio-2010
iverilog
android-emulator
graphql-js
pyresttest
mailing-list
documentum
bootstrap-switch
orc
smartgwt
google-tasks-api
l20n
scheduled-tasks
parceler
error-logging
android-permissions
neo4j.rb
bosun
maven-surefire-plugin
fluent-migrator
cell
jstree
unrar
msdeploy
openbravo
miniprofiler
region
audit
winsock
restful-architecture
nppexec
django-crispy-forms
ms-dos
sspi
yoast
axis
cyanogenmod
beeline
iptv
sesame
openerp-6
prefetch
bpms
oracle-fusion-apps
thread-exceptions
fuzzer
raw-sockets
android-sdcard
meld
simian
gdl
android-handler
mobilefirst-server
mathematical-expressions
dos2unix
rubber
nesper
dmake
screwturn
flipboard
eclim
mp4parser
lru
node.js-stream
examine
arrow
fitch-proofs
mkannotation
django-apps
dynamic-c
litespeed
servercontrol
server-variables
sql-parametrized-query
kohana-auth
browser-based
yahoo-maps
projectpier
sqlsitemapprovider
database-cloning
acceleration

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile