On my database I have the table reserves, on the reserves I have inserted the following data:
Then I used the following query(this is just one part):
$checkInresult = mysql_result(mysql_query("SELECT DAYOFMONTH(`checkIn`) FROM `reserves` WHERE `idApart` = 1 AND `expired` = 0"), 0,0);
$checkOutresult = mysql_result(mysql_query("SELECT DAYOFMONTH(`checkOut`) FROM `reserves` WHERE `idApart` = 1 AND `expired` = 0"), 0,0);
$curDay = mysql_result(mysql_query("SELECT DAYOFMONTH(CURDATE())"), 0,0);
if((1 == $curDay) && (1 >= $checkInresult) && (1 <= $checkOutresult)){
$day1 = "currentO";
}elseif(1 == $curDay){
$day1 = "currentA";
}elseif((1 >= $checkInresult) && (1 <= $checkOutresult)){
$day1 = "occupiedDay";
}else{
$day1 = "availableDay";
}
And the html(only one part too):
<div id="calendar">
<h1>June</h1>
<table>
<tr>
<td class="<?php echo $day1; ?>"><center>1</center></td>
<td class="<?php echo $day2; ?>"><center>2</center></td>
<td class="<?php echo $day3; ?>"><center>3</center></td>
<td class="<?php echo $day4; ?>"><center>4</center></td>
<td class="<?php echo $day5; ?>"><center>5</center></td>
<td class="<?php echo $day6; ?>"><center>6</center></td>
<td class="<?php echo $day7; ?>"><center>7</center></td>
</tr>
And the result is this:
And I want the 2nd data to apear marked with red too without making too many ifs like same variable contains the checkIn and checkOut data from both datas. Is it possible? Or is it too confusing? :s