function check_dates($checkin,$checkout)
{
//convert times to right format
$begindate = date('Y-m-d',(strtotime($checkin)));
$enddate = date('Y-m-d',(strtotime($checkout)));
//how many days are in between
$date= round((strtotime($enddate) - strtotime($begindate)) / (60 * 60 * 24));
//gather all the dates from the client and check database
for ($i = 0; $i<$date; $i++) {
$newdates = strtotime('+'.$i.' day', strtotime($begindate));
$booking[$i] = date('Y-m-d', $newdates);
//compare dates to database
$d = new Day();
$d->where('day',$booking[$i]);
$d->get();
$id = $d->id; // gives me the id from days table to use to compare to days_reservations tabe;