i have this function to calculate number of staff based on number of activity that they have attend and group it by their gred. but the problem is it return wrong value. can anyone tell me where is the error in my coding.:elderly:
function countSix($a,$f)
{
$sql = "SELECT * FROM staf_info INNER JOIN aktiviti_staf ON staf_info.id=aktiviti_staf.id INNER JOIN aktiviti ON aktiviti_staf.id_aktiviti=aktiviti.id_aktiviti WHERE staf_info.id_kumpulan = '".$a."' AND year(tarikh_awal) LIKE '%".$f."'";
$query= mysql_query($sql) or die("Error: " .mysql_error());
$row=mysql_num_rows($query);
$num=1;
$f=0;
if($row!=0)
{
while( $data=mysql_fetch_assoc($query))
{
$b=$data['bil_hari']+$data['hari_kursus'];
if($b == 6)
{
$e = countStaf($data['id'],$data['id_aktiviti']);
$f = $f + $e;
}
}
}
return $f;
}
function countStaf($c,$d)
{
$sql = "SELECT COUNT(*) AS STAFCOUNT FROM aktiviti_staf WHERE id = '".$c."' AND id_aktiviti = '".$d."'";
$query= mysql_query($sql) or die("Error: " .mysql_error());
$row=mysql_num_rows($query);
$result = mysql_fetch_array($query);
return $result['STAFCOUNT'];
}