Jump to content

count doesnt work


piheshpi90

Recommended Posts

i want to create function that calculate worker that attend 6 days activity on year B and group it by their gred.

so i use this coding but it give wrong result


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'];
}

 

 

i can't seem to find the error..

help me please!! :'(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.