Welcome Guest, Not a member yet? Register   Sign In
Need Help
#6

[eluser]kre8ivdesigns[/eluser]
So I threw all that code to first focus on checking dates to the database. The following code has shown promise but I want to get a sanity check from you talented people.

Code:
function datecheck()
    {
        $date = $this->input->post('begindate');
        $days = $this->input->post('number_days');
        global $available;
        
        //retrieves dates and id from database
        $this->db->select("id,booked_dates");
        $Q = $this->db->get('bookedcalendar');
        if ($Q->num_rows() >0){
            foreach ($Q->result_array() as $row){
                $data[] = $row['booked_dates'];
                $id = $row['id'];
            }
        }
        
        //takes dates from client
        for ($i = 1; $i<$days; $i++) {        
            $newdates = strtotime('+'.$i.' day', strtotime($date));
            $booking[$i] = date('Y-m-d', $newdates);
        }
        
        
        //compare dates to database
        for ($i = 0; $i < $id; $i++){
            if (array_search($data[$i],$booking) != 0){
                $available = 1;
            }            
         }
        
        //if dates match then have them change them change dates
        if ($available == 1){
            echo 'Please change date';
        } else {
            echo 'Book Room';
        }
        
        $Q->free_result();
        return $data;
    }
}


Messages In This Thread
Need Help - by El Forum - 07-31-2010, 11:43 AM
Need Help - by El Forum - 07-31-2010, 12:38 PM
Need Help - by El Forum - 07-31-2010, 12:53 PM
Need Help - by El Forum - 07-31-2010, 01:00 PM
Need Help - by El Forum - 07-31-2010, 01:21 PM
Need Help - by El Forum - 08-01-2010, 02:45 PM
Need Help - by El Forum - 08-02-2010, 02:18 PM
Need Help - by El Forum - 08-02-2010, 02:31 PM
Need Help - by El Forum - 08-16-2010, 02:22 PM



Theme © iAndrew 2016 - Forum software by © MyBB