Calendrier de l'avent petit souci

Résolu/Fermé
David987 Messages postés 121 Date d'inscription samedi 19 décembre 2015 Statut Membre Dernière intervention 16 octobre 2022 - 27 nov. 2017 à 11:56
David987 Messages postés 121 Date d'inscription samedi 19 décembre 2015 Statut Membre Dernière intervention 16 octobre 2022 - 27 nov. 2017 à 22:37
Bonjour,

Voici mon souci, j'aimerais faire un calendrier de l'avent donc voici ce que j'ai déjà fait :

L'image, les coordonnées.
La condition du jour est faite MAIS le souci c'est que même si on est le 2 du mois et bien le 1 est cliquable uniquement.

Voici mon code :

if(time() > mktime(0, 0, 0, 11, 1, 2017)){  echo '<area shape="rect" coords="456,144,558,244" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 13, 2017)) { echo '<area shape="rect" coords="563,355,663,455" target="_blank" href="jours/tune.php">';}
 elseif(time() > mktime(0, 0, 0, 11, 14, 2017))  {echo '<area shape="rect" coords="243,248,346,346" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 15, 2017)){  echo '<area shape="rect" coords="561,250,665,349" target="_blank" href="jours/objet.php">';} 
 elseif(time() > mktime(0, 0, 0, 11, 16, 2017)) { echo '<area shape="rect" coords="137,460,239,563" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 17, 2017)) { echo '<area shape="rect" coords="135,353,239,457" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 13, 2017))  {echo '<area shape="rect" coords="455,463,554,562" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 19, 2017))  {echo '<area shape="rect" coords="245,142,344,243" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 20, 2017))  {echo '<area shape="rect" coords="562,460,663,561" target="_blank" href="jours/pokemon.php">';}
 elseif(time() > mktime(0, 0, 0, 11, 21, 2017))  {echo '<area shape="rect" coords="351,463,456,562" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 22, 2017))  {echo '<area shape="rect" coords="241,460,345,561" target="_blank" href="jours/objet.php">';} 
 elseif(time() > mktime(0, 0, 0, 11, 23, 2017))  {echo '<area shape="rect" coords="456,356,560,456" target="_blank" href="jours/tune.php">';} 
 elseif(time() > mktime(0, 0, 0, 11, 24, 2017))  {echo '<area shape="rect" coords="455,38,559,140" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 25, 2017))  {echo '<area shape="rect" coords="347,247,451,350" target="_blank" href="jours/pokemon.php">';}
 elseif(time() > mktime(0, 0, 0, 11, 2, 2017))  {echo '<area shape="rect" coords="243,354,345,456" target="_blank" href="jours/pokemon.php">';} 
 elseif(time() > mktime(0, 0, 0, 11, 3, 2017))  {echo '<area shape="rect" coords="138,141,237,244" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 4, 2017))  {echo '<area shape="rect" coords="562,144,665,245" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 5, 2017))  {echo '<area shape="rect" coords="243,36,345,138" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 6, 2017)) { echo '<area shape="rect" coords="348,351,451,453" target="_blank" href="jours/objet.php">';}
 elseif(time() > mktime(0, 0, 0, 11, 7, 2017))  {echo '<area shape="rect" coords="559,38,666,139" target="_blank" href="jours/tune.php">';} 
 elseif(time() > mktime(0, 0, 0, 11, 8, 2017)){  echo '<area shape="rect" coords="136,247,241,354" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 9, 2017)) { echo '<area shape="rect" coords="349,141,452,242" target="_blank" href="jours/pokemon.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 10, 2017)) { echo '<area shape="rect" coords="137,37,238,137" target="_blank" href="jours/objet.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 11, 2017))  {echo '<area shape="rect" coords="454,248,559,349" target="_blank" href="jours/tune.php">'; }
 elseif(time() > mktime(0, 0, 0, 11, 12, 2017))  {echo '<area shape="rect" coords="350,36,452,137" target="_blank" href="jours/objet.php">'; }
 else{} ?>


Je vois le souci car, en faite la première condition est toujours bonne donc le script ne passe pas à d'autre ligne.

Ma question est : Comment adapter mon code pour que lorsqu'on est le 2 du mois la case 1 n'est plus cliquable mais la 2 oui et ainsi de suite.

Merci par avance pour votre aide.

1 réponse

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
27 nov. 2017 à 11:59

en faite la première condition est toujours bonne donc le script ne passe pas à d'autre ligne


Dans ce cas... inverse tes conditions.
Commence par les plus restrictives

ou mets des "sous" if
if(mapremierecondtion){

   if(masecondecondition){

   }else{

    }
}else

}

0
David987 Messages postés 121 Date d'inscription samedi 19 décembre 2015 Statut Membre Dernière intervention 16 octobre 2022 1
27 nov. 2017 à 22:37
Merci beaucoup, j'y avais pas pensé, que je peux être bête par moment.
0