troubleshooting Question

Store values in array before processing from database?

Avatar of hej613
hej613 asked on
13 Comments4 Solutions335 ViewsLast Modified:
Morning Experts - I have a page I am looking to write to replace some OLD code on one of our applications - Basically its a head count for a jail - I was wondering how to best accomplish it.  For example, I need a count of all males and females currently in prison, then I need a count of all sentenced and unsentenced males/females in the prison, finally I need a count of all people currently in prison by location code... I am curious if its better to write server SQL queries to get the data (several small count statements) or just one main large select statement and somehow process through the code with PHP and update counters as I go?

For example some of the fields I have in the database (just the ones I'm interested in)

Sentenced status

I would think I could just do a
select * from JMS_01MAST where active_booking is not null

and in the while statement somehow do
if (gender = 'M')
else if (gender = 'F')

Then I could redo that same statement somehow and count the other columns?

I know there must be a way to get this all in one big pass, but I cant figure it out...
Join our community to see this answer!
Unlock 4 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 4 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros