Espero que alguien me pueda ayudar ya que no soy tan experto en php.
Mi problema es el siguiente, tengo un calendario en php y cuando busco la conexión con la BD para que me marque los días que están ocupados simplemente el elseif no me lo marca en cambio si lo pongo manual si los marca, como puedo realizar esto para que el elseif sea tanto como numero de registros tenga en mi BD. Ya he intentado separar toda la fecha por día, mes y año pero también tengo en mi BD en el campo fecha, la fecha con mktime, por favor AYUDA
el codigo es el siguiente:
esto es para que lo muestre en mi pagina.
Código PHP:
<?php
require_once("coiCalendar.class.php");
$myCelandar = new coiCalendar();
$mk2=$month;
$mk=$year;
$myCelandar->showCalendar($mk,$mk2);
?>
Código PHP:
<?php
include ("fecha.php");
class coiCalendar{
function showCalendar($year=0,$month=0){
if ($month == "01"){
$monthnow = "Enero";
}
if ($month == "02"){
$monthnow = "Febrero";
}
if ($month == "03"){
$monthnow = "Marzo";
}
if ($month == "04"){
$monthnow = "Abril";
}
if ($month == "05"){
$monthnow = "Mayo";
}
if ($month == "06"){
$monthnow = "Junio";
}
if ($month == "07"){
$monthnow = "Julio";
}
if ($month == "08"){
$monthnow = "Agosto";
}
if ($month == "09"){
$monthnow = "Septiembre";
}
if ($month == "10"){
$monthnow = "Octubre";
}
if ($month == "11"){
$monthnow = "Noviembre";
}
if ($month == "12"){
$monthnow = "Diciembre";
}
// Get today, reference day, first day and last day info
if (($year == 0) || ($month == 0)){
$referenceDay = getdate();
} else {
$referenceDay = getdate(mktime(0,0,0,$month,1,$year));
}
$firstDay = getdate(mktime(0,0,0,$referenceDay['mon'],1,$referenceDay['year']));
$lastDay = getdate(mktime(0,0,0,$referenceDay['mon']+1,0,$referenceDay['year']));
$today = getdate();
// Create a table with the necessary header informations
echo '<table class="month">';
echo ' <tr ><th colspan="7">'.$monthnow." - ".$referenceDay['year']."</th></tr>";
echo ' <tr class="days" class="menu4"><td>Lu</td><td>Ma</td><td>Mi</td><td>Ju</td><td>Vi</td><td>Sa</td><td>Do</td></tr>';
// Display the first calendar row with correct positioning
echo '<tr>';
if ($firstDay['wday'] == 0) $firstDay['wday'] = 7;
for($i=1;$i<$firstDay['wday'];$i++){
echo '<td> </td>';
}
$actday = 0;
for($i=$firstDay['wday'];$i<=7;$i++){
$actday++;
include("conexion.php"); //conexion BD
$resultados=mysql_query("SELECT * FROM agenda where id='$_REQUEST[id]' ORDER BY fecha " , $link);
while ($rowx = mysql_fetch_array($resultados)){
$dia=$rowx["dia_ini"];
$com=$rowx["mes_ini"];
$comq=$rowx["ano_ini"];
$mesano="$com/$comq";
$ok="$month/$year";
if (($actday == $today['mday']) && ($today['mon'] == $month)) {
$class = ' class="actday"';
}
//no me muestra nada y si modifoco por ejemlo $dia por 2 y $mesano por 08/2008 me marca el dia y si pongo otro elseif tambien con la fecha manual tambien me lo marca pero con la BD NO
elseif (($actday == $dia) && ($mesano== $ok)) {
$class = ' class="actday1"';
} else {
$class = '';
}
} //del while
echo "<td$class><a href='miagendav.php?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
}
echo '</tr>';
//Get how many complete weeks are in the actual month
$fullWeeks = floor(($lastDay['mday']-$actday)/7);
for ($i=0;$i<$fullWeeks;$i++){
echo '<tr>';
for ($j=0;$j<7;$j++){
$actday++;
if (($actday == $today['mday']) && ($today['mon'] == $month)) {
$class = ' class="actday"';
} else {
$class = '';
}
echo "<td$class><a href='miagendav.php?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
}
echo '</tr>';
}
//Now display the rest of the month
if ($actday < $lastDay['mday']){
echo '<tr>';
for ($i=0; $i<7;$i++){
$actday++;
if (($actday == $today['mday']) && ($today['mon'] == $month)) {
$class = ' class="actday"';
} else {
$class = '';
}
if ($actday <= $lastDay['mday']){
echo "<td$class><a href='miagendav.php?id=".$_SESSION[idusuario]."&dia=$actday&mes=$month&año=$year' class='menu4'>$actday</a></td>";
}
else {
echo '<td> </td>';
}
}
echo '</tr>';
}
echo '</table>';
}
}
?>