voila je bidouille j'essaye de custumiser un script d'agenda avec une base de donnée
et c'est un peu coton,
en effet ma bdd stocke les date en timestamp unix,
et je n'arrive pas à convertir toutes mes dates (celle du mois du calendrier et celles du mois prédédent et suivant qui servent à boucher les trous du tableau) toute en demandant à php de rechercher si celles ci ne trouvent pas dans la bdd, si oui il doit alors afficher les cases de manière différentes (en rouge par exemple),ici le script se contente d'afficher la case de la date en vert,
pourriez vous m'aidez?
merci d'avance

<? php
include ("connexxion/conec.php");
$anneTitre['jan']="Janvier"; $anneTitre['jun']="Juin";
$anneTitre['feb']="Février"; $anneTitre['aug']="Aout";
$anneTitre['mar']="Mars"; $anneTitre['sep']="Septembre";
$anneTitre['apr']="Avril"; $anneTitre['oct']="Octobre";
$anneTitre['may']="Mai"; $anneTitre['nov']="Novembre";
$anneTitre['jul']="Juillet"; $anneTitre['dec']="Décembre";
if(!isset($_REQUEST['date'])){
$date = mktime(0,0,0,date('m'), date('d'), date('Y'));
}else {
$date = $_REQUEST['date'];
}
$la=mktime(0,0,0,date('m'), date('d'), date('Y'));
$day = date('d', $date);
$month = date('m', $date);
$year = date('Y', $date);
$month_start = mktime(0,0,0,$month, 1, $year);
$month_name = date('M', $month_start);
$monthTitre=$anneTitre[strtolower($month_name)];
$month_start_day = date('D', $month_start);
switch($month_start_day){
case "Mon": $offset = 0; break;
case "Tue": $offset = 1; break;
case "Wed": $offset = 2; break;
case "Thu": $offset = 3; break;
case "Fri": $offset = 4; break;
case "Sat": $offset = 5; break;
case "Sun": $offset = 6; break;
}
// calcul du nombre de jours du mois précedent:$num_days_last
if($month == 1){
$num_days_last = cal_days_in_month(0, 12, ($year -1));
} else {
$num_days_last = cal_days_in_month(0, ($month -1), $year);
}
// fin calcul $num_days_last
$num_days_current = cal_days_in_month(0, $month, $year); // nombre de jours du mois courant
for($i = 1; $i <= $num_days_current; $i++){
$num_days_array[] = $i;
}
for($i = 1; $i <= $num_days_last; $i++){
$num_days_last_array[] = $i;
}
if($offset > 0){
$offset_correction = array_slice($num_days_last_array, -$offset, $offset);
$new_count = array_merge($offset_correction, $num_days_array);
$offset_count = count($offset_correction); //nombre de jour du mois précédent dans le tableau
}
else {
$offset_count = 0;
$new_count = $num_days_array;
}
$current_num = count($new_count);
if($current_num > 35){
$num_weeks = 6;
$outset = (42 - $current_num);
} elseif($current_num < 35){
$num_weeks = 5;
$outset = (35 - $current_num);
}
if($current_num == 35){
$num_weeks = 5;
$outset = 0;
}
for($i = 1; $i <= $outset; $i++){
$new_count[] = $i;
}
$weeks = array_chunk($new_count, 7);
$previous_link = "<a href=\"agenda2.php?a=date&date=";
if($month == 1){
$previous_link .= mktime(0,0,0,12,$day,($year -1));
} else {
$previous_link .= mktime(0,0,0,($month -1),$day,$year);
}
$previous_link .= "\"><< Précédent</a>";
$next_link = "<a href=\"agenda2.php?a=date&date=";
if($month == 12){
$next_link .= mktime(0,0,0,1,$day,($year + 1));
} else {
$next_link .= mktime(0,0,0,($month +1),$day,$year);
}
$next_link .= "\">Suivant >></a>";
echo "<br /><table align=\"center\" border=\"1\" cellpadding=\"2\" cellspacing=\"0\" width=\"600\" class=\"calendar\">".
"<tr>".
"<td colspan=\"7\">".
"<table width=\"100%\" align=\"center\">".
"<tr>".
"<td colspan=\"2\" width=\"100\" align=\"left\">$previous_link</td>".
"<td colspan=\"3\" align=\"center\">$monthTitre $year</td>".
"<td colspan=\"2\" width=\"100\" align=\"right\">$next_link</td>".
"</tr>".
"</table>".
"</td>".
"<tr height=\"10\">".
"<td bgcolor=\"#00CC66\">Lundi</td><td bgcolor=\"#00CC66\">Mardi</td><td bgcolor=\"#00CC66\">Mercredi</td><td
bgcolor=\"#00CC66\">Jeudi</td><td bgcolor=\"#00CC66\">Vendredi</td><td bgcolor=\"#00CC66\">Samedi</td><td
bgcolor=\"#00CC66\">Dimanche</td>".
"</tr>";
$i = 0;
include("sql.php");
foreach($weeks AS $week){
echo "<tr height=\"20\">";
foreach($week as $d){
if($i < $offset_count){
$day_link = $d;
echo "<td class=\"nonmonthdays\">$day_link </td>";
}
if(($i >= $offset_count) && ($i < ($num_weeks * 7) - $outset)){
$dateLa=mktime(0,0,0,$month,$d,$year);
// attention $dateLa étant la date d'aujourdh'ui la recherche
// suivante est fausse. Le script devrait chercher si aucune des dates affichées dans le calendrier
// (fin du mois prédédent affiché , mois affiché, début mois suivant affiché ) n'est présente ds BDD $extraire1=mysql_query("select * from agenda_events WHERE date='$dateLa'");
$nbrEvents1=mysql_numrows($extraire1);
if($nbrEvents1>0){ $eventsHere=" <span class=\"gros\">*</span>"; }else{ $eventsHere="";}
$day_link = "<a href=\"index.php?a=date&date=".mktime(0,0,0,$month,$d,$year)."\">$d</a> $eventsHere";
if($la == mktime(0,0,0,$month,$d,$year)){
echo "<td bgcolor=\"#ffff99\">$day_link</td>";
}elseif($day==$d){
echo "<td class=\"clic\">$day_link</td>";
}else{
echo "<td class=\"days\">$day_link</td>";
}
}elseif(($outset > 0)) {
if(($i >= ($num_weeks * 7) - $outset)){
$day_link = $d;
echo "<td class=\"nonmonthdays\">$day_link</td>";
}
}
$i++;
}
echo "</tr>";
}
echo '</table>';
?>