vendredi 1 février 2019

PHP If else and some logics

I just having some problem of if/else or somewhat logical things in here, I have a fullcalendar that shows all the date that being reserve, I limit the reserve by 5 per date, but when I having a 2 or more reserved on the date and having reserve by other date, It gives me the same result as 4.

        $res = mysqli_query($db,$query);
        $count = mysqli_num_rows($res);
        $count = 5 - $count;
        $date_changed = "";
        $reserve_id = 0;

        foreach ($res as $row) 
        {
            date_default_timezone_set('Asia/Manila');

            $current_timestamp = strtotime($row["dateend"] . '+1 day');

            $time = date("Y/m/d",$current_timestamp);


            if($row["datestart"] == $date_changed)
            {

            }
            else
            {
                if(empty($count))
                {
                    $count = '0';
                }
                else
                {
                    if($reserve_id == $row['reserve_id'])
                    {
                        $count;
                    }
                    else
                    {
                        $count = 4;
                    }
                }

                $data[] = array(
                    'id'    => $row["reserve_id"],
                    'title' => $count,
                    'start' => $row["datestart"],
                    'end' => $time,
                    'color' =>getColor($row["status"])
                );
                $date_changed = $row["datestart"];
                $reserve_id = $row["reserve_id"];
            }

        }

        echo json_encode($data);

This is image of the error with captions

All i had tried is to get the right available on the 2nd of febuary 2018 and not the others.

Aucun commentaire:

Enregistrer un commentaire