Good afternoon experts.
I'm trying to count different Misdemeanor and Felony charges in our jail system. When someone is booked in jail, they are given a booking number, that booking number may have multiple charges associated with it. If all the charges are Misdemeanor, then I want to count 1 misd count, if there are multiple misd and one felony charge in that booking, then that booking should count as a felony booking.
My current code that is counting each "CHARGE" separately (which is not desired) is below
$sql3 = "select * from jms_03mast where jm3_booking_num = '".$row['jm1_active_booking']."'";
$result3 = $myConn->query($sql3);
while($row3 =& $result3->fetchRow(DB_FETCHMODE_ASSOC))
//this is a total count, per charge, could have multiple per booking....
if($row3['jm3_felony'] == 'F' || $row3['jm3_felony'] == 'Y')
if($row3['jm3_felony'] == 'M' || $row3['jm3_felony'] == 'N')
As you can see i'm looping through a charge table (jms_03mast) and counting each charge per booking... I'm not sure how I would do this and only get 1 count per booking...
As a quick example:
Booking# Charge# Felony/misd:
01 01 M
01 02 M
01 03 M
02 01 M
02 02 F
So in the above example, I would have a total count of '2' bookings and 1 felony booking (since booking 02 has a felony charge entered) and 1 misd booking.
I hope I have explained this well enough, its been giving me a headache trying to figure it out!