Buenas tardes, os vengo leyendo desde hace unos meses que me animé a montar una página web y ahora me he encontrado con un problema al que no le encuentro solución.
En este calendario que estoy montando, necesito que cuando el usuario marque una fecha y obtenga las variables $day, $month y $year se resalte ese día seleccionado de un color diferente.
A continuación os adjunto el código para que me echeis una mano.
<style>
.today{background-color:#00ff00;}
.event{background-color:brown;}
.past{background-color:grey;}
.full{background-color:#0000ff;}
.pasado{color:#FF0000;}
.seleccion{color:white;}
</style>
<?php
if (isset($_GET['day'])){
$day=$_GET['day'];}
else{$day=date("d");}
if (isset($_GET['month'])){
$month=$_GET['month'];}
else{$month=date("m");}
if (isset($_GET['year'])){
$year=$_GET['year'];}
else{$year=date("Y");}
?>
<table border='1'>
<input id="obtener" type="button" value="envio" onclick="envia(<?php if ($day < 10) {echo "'0'+$day+'/'+";}else{echo "$day+'/'+";}
if ($month < 10) {echo "'0'+$month+'/'+";}else{echo "$month+'/'+";}echo "$year"; ?>);">
<p><label for="from">Desde</label> <input type="textarea" id="from" name="from" placeholder="dd/mm/aaaa" pattern="(0[1-9]|1[0-9]|2[0-9]|3[01])/(0[1-9]|1[012])/[0-9]{4}" value="<?php echo "$day/$month/$year"; ?>" required/>
<tr>
<td><input style='width:50px;' type='button' value='<' name='previousbutton' onclick="goLastMonth(<?php echo $month.",".$year ?>)"></td>
<td colspan='5'><?php echo $monthName.", ".$year; ?></td>
<td><input style='width:50px;' type='button' value='>' name='nextbutton' onclick="goNextMonth(<?php echo $month.",".$year ?>)"></td>
</tr>
<tr>
<td width='50px' height='50px'>Mon</td>
<td width='50px' height='50px'>Tue</td>
<td width='50px' height='50px'>Wed</td>
<td width='50px' height='50px'>Thu</td>
<td width='50px' height='50px'>Fri</td>
<td width='50px' height='50px'>Sat</td>
<td width='50px' height='50px' >Sun</td>
</tr>
<?php
echo "<tr>";
for($i=1; $i<$numDays+1; $i++, $counter++){
$timeStamp=strtotime ("$year-$month-$i");
if($i==1){
$firstDay=date("w",$timeStamp);
for($j=1; $j<$firstDay; $j++, $counter++){
echo "<td> </td>";
}}
if($counter %7 == 0){
echo "</tr><tr>";}
$monthstring=$month;
$monthlength=strlen($monthstring);
$daystring=$i;
$daylength= strlen($daystring);
if($monthlength <=1){
$monthstring="0".$monthstring;
}
if($daylength <=1){
$daystring="0".$daystring;
}
$todaysDate=date("d/m/Y");
echo "<td onMouseOver=this.style.background='yellow' onMouseOut=this.style.background='' width='50px' height='50px' align='center'";
if (date("Y/m/d") > $year.'/'.$monthstring.'/'.$daystring){echo "class='past'";}
if($todaysDate==$daystring.'/'.$monthstring.'/'.$year){
echo"class='today'";
}
else{
$sqlCount="select*from eventcalender where
(Llegada <= '".$year.'/'.$monthstring.'/'.$daystring."' AND Salida >'".$year.'/'.$monthstring.'/'.$daystring."')
";
$noOfEvent=mysql_num_rows(mysql_query($sqlCount));
if($noOfEvent >=0 AND $noOfEvent <=3 AND date("Y/m/d") < $year.'/'.$monthstring.'/'.$daystring )
{echo "class='event' ";
}
elseif($noOfEvent >=4)
{echo "class='full'";}
}
if (date("Y/m/d") <= $year.'/'.$monthstring.'/'.$daystring and $noOfEvent < 4){
echo " ><a href='".$_SERVER['PHP_SELF']."?day=".$daystring."&month=".$monthstring."&year= ".$year."' onclick='ilumina(this)' > ".$i."</a>";
echo "<p>300 €</p></td>";}else{echo "><font color='grey' > ".$i."</font></a>";}
}
echo "</tr>";
?>
</table>