PHP ERROR Message: Invalid argument supplied for foreach() WHEN i implementasion date filter

PHP ERROR Message: Invalid argument supplied for foreach() WHEN i implementasion date filter

please help me, here I want to use filter by date using datepicker
but the error occurred "Message: Invalid argument supplied for foreach ()"

this is my code:

model:

    public function get_allDprtDetail($DepartmentID)
    {
        if(isset($_GET['tanggal'])){
            $tgl = $_GET['tanggal'];

        $datas = "
        SELECT 
....
    IF
        ( emp0003.NIK = v_dvc0004_test.NIK, 'Hadir', 'Tidak Hadir' ) AS Attendance 
    FROM
        emp0001
        INNER JOIN emp0003 ON emp0003.DepartmentID = emp0001.DepartmentID
        
LEFT JOIN v_dvc0004_test ON emp0003.NIK = v_dvc0004_test.NIK *AND DATE(v_dvc0004_test.Enroll) = '$tgl'
        JOIN emp0002 ON emp0002.PositionID = emp0003.PositionID
        LEFT JOIN shift ON emp0003.Shift_ID = shift.Shift_ID 
    WHERE
        emp0001.DepartmentID = '$DepartmentID' 
        AND emp0003.IsActive = 'T' 
    ORDER BY
        v_dvc0004_test.Enroll ASC
    
    ";
        $query = $this->db->query($datas);
        return $query->result();}
    }

view:


     </div>
    
                                        <form method="get">
                <label>PILIH TANGGAL</label>
                <input type="date" name="tanggal">
                <input type="submit" value="FILTER">
            </form>  
                                ....
    
                            <tbody>
                                <?php foreach ($getDepartDetail as $us) { ?>
                                    <tr>
                                        <td><?php echo $us->Name ?></td>
                                        <td><?php echo $us->NIK ?></td>
                                        <td><?php echo $us->gender ?></td>
                                        <td><?php echo $us->PositionDesc ?></td>
                                        <td><?php echo $us->Shift ?></td>
                                        <td><?php echo $us->tgl ?></td>
                                        <td><?php echo $us->Attendance ?></td>
                                        <td><a class="btn btn-info" href="<?php echo site_url('data_detail/detail_datas/vieworc/' . $us->NIK); ?>">Detail</a></td>
                                    </tr>
                                <?php } ?>
                            </tbody>
                        ....

12 thoughts on “PHP ERROR Message: Invalid argument supplied for foreach() WHEN i implementasion date filter”

  1. hey there and thank you for your information – I have
    certainly picked up anything new from right here. I did however expertise a few technical issues using this website, since I experienced to reload the website a lot of times previous to I
    could get it to load properly. I had been wondering if your hosting
    is OK? Not that I’m complaining, but sluggish loading instances times will very frequently affect your placement in google and could damage your high quality score if advertising
    and marketing with Adwords. Anyway I’m adding this RSS to
    my email and can look out for a lot more of your respective intriguing content.
    Ensure that you update this again soon. https://herreramedical.org/hydroxychloroquine

    Reply

Leave a Comment