Foros del Web » Programando para Internet » PHP »

Dejar fecha marcada en calendario

Estas en el tema de Dejar fecha marcada en calendario en el foro de PHP en Foros del Web. 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 ...
  #1 (permalink)  
Antiguo 08/03/2016, 12:55
 
Fecha de Ingreso: marzo-2016
Mensajes: 1
Antigüedad: 8 años, 1 mes
Puntos: 0
Dejar fecha marcada en calendario

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>&nbsp;</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>
  #2 (permalink)  
Antiguo 10/03/2016, 06:10
Avatar de loncho_rojas
Colaborador
 
Fecha de Ingreso: octubre-2008
Ubicación: En el mejor lugar del mundo
Mensajes: 2.704
Antigüedad: 15 años, 6 meses
Puntos: 175
Respuesta: Dejar fecha marcada en calendario

Lo que intentas hacer es básicamente modificar el DOM.. por ende deberás emplear Javascript, Ajax, jQuery o similar para ello.. mira en google algún calendario en esas tecnologías...
__________________
Ayudo con lo que puedo en el foro, y solo en el foro.. NO MENSAJES PRIVADOS.. NO EMAILS NI SKYPE u OTROS.

Antes de hacer un TOPICO piensa si puedes hallarlo en Google o en el Buscador del Foro...
  #3 (permalink)  
Antiguo 10/03/2016, 09:58
 
Fecha de Ingreso: septiembre-2014
Mensajes: 79
Antigüedad: 9 años, 8 meses
Puntos: 0
Respuesta: Dejar fecha marcada en calendario

Hola, coincido... mandale DATEPICKER:
https://jqueryui.com/datepicker/
Y despues le mandas al server a travez de un input el dia, mes año, hora o lo que quieras.
¿Es eso lo que buscabas?
Saludos

Etiquetas: calendario, dejar, fecha, select, sql, variable
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 17:23.