I've been on this for a week and can not find a solution maybe some help well clear the way
EXPLANATION:
I have a MySQL data base the three (3) tables I'm working with are appointments, jobs and services
The Task:
Count the number of occurrences of a specific ID in a given month
i.e.. If I had six (6) appointments and these appointments had several jobs I want to get the qty of each job to build a table like example
Job Name | qty | .....
Cleaning | 12 | .....
Washing | 16 | .....
Drying | 9 | .....
SITUATION: the date is in the appointments table
and the app_id connects the appointment to jobs and there is a services table which is just the list of service to choose from this id is in the jobs table
WHAT I HAVE
A drop down to show each month
if (!$val) {
$this_month = date("F");
} else {
$this_month = $val;
}
$months = array("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"Novermber",
"December");
while(list($key,$val) = each($months)) {
if ($val == $this_month) {
$ms .= "<option value=\"$php_self?val=$val&page=accrec&area=fee reports\" selected>
$val</option>";
$j = $key+1;
} else {
$ms .= "<option value=\"$php_self?val=$val&page=accrec&area=fee reports\">
$val</option>";
}
}
<select size="1" NAME="selectName" onChange="goto_URL(this.form.selectName)">
<? echo "$ms"; ?>
</select>
Next I select from appointments and jobs that completed between the beginning and end of given month
$get_sd = db_query("SELECT FROM appointments, jobs
WHERE appointments.app_id = jobs.app_id
AND appointments.date_completed >= '$sdate'
AND appointments.date_completed <= '$edate'
AND service_type = 'SD'
GROUP BY jobs.service_id");
while($sd_row = db_fetch_array($get_sd)) {
here is where I'm having trouble counting I tried array_count_value() nothing but errors or stores all values as 1 value
if anybody can help it would be appreciated
}