Bonjours je me suis remis depuis peu au php, j'essaie de faire un site fictif sur un festival de modélisme et je bloque depuis un peu sur un problème de planning.
Je m'explique, pendant la totalité du festival plusieurs événement sont prévus j'essaie donc d'en faire un planning récapitulant tous les événements avec leurs horaires.
d'abord pour créer ce tableau je me sert de ces deux tables :
Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 CREATE TABLE `t_festival_fes` ( `fes_nom` varchar(50) NOT NULL, `fes_lieu` varchar(45) NOT NULL, `fes_datedebut` date NOT NULL, `fes_datefin` date NOT NULL, `fes_horaireouverture` time NOT NULL, `fes_horairefermeture` time NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8; CREATE TABLE `t_evenement_even` ( `even_id` int(11) NOT NULL, `even_nom` varchar(50) NOT NULL, `even_descriptif` longtext NOT NULL, `even_datehorairedebut` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `even_datehorairefin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', `lieu_id` int(11) DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ensuite après avoir récupérer quelques requête je créé mon tableau grace a PHP ce qui donne ceci :
Cela me gènere le code HTML suivant :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77 //fonction permettant de mettre une horaire (H : min : sec) en seconde function timetosec($str_time) { $str_time = preg_replace("/^([\d]{1,2})\:([\d]{2})$/", "00:$1:$2", $str_time); sscanf($str_time, "%d:%d:%d", $hours, $minutes, $seconds); return $hours * 3600 + $minutes * 60 + $seconds; } //fonction permettant de mettre un entier de seconde en heure (H : min) function sectotime($str_time) { $m=(int)$str_time%3600; $h=(int)$str_time/3600; if ($h<10) { $h='0'.$h; } if ($m<10) { $m='0'.$m; } return $h.':'.$m; } $date1 = strtotime($temps->fes_datedebut); $date2 = strtotime($temps->fes_datefin); $heure1= timetosec($temps->fes_horaireouverture); $heure2= timetosec($temps->fes_horairefermeture); ?> <table class="bordered centered"> <thead> <tr> <th></th> <?php setlocale (LC_TIME, 'fr_FR.utf8','fra'); for ($i = $date1; $i <= $date2; $i=$i+86400) {echo '<th>'.strftime("%A %d %B", $i).'</th>';} ?> </tr> </thead> </tbody> <?php $compt = false; for ($i = $heure1; $i <= $heure2-1; $i=$i+3600) { ?> <tr> <?php echo '<td style="height:100px;vertical-align:top;">'.sectotime($i).'</td>'; if ($compt == false) { for ($j = $date1; $j <= $date2; $j=$j+86400) { ?><td rowspan="<?php echo ($heure2-$heure1-1)/3600 ; ?>" height="<?php echo ($heure2-$heure1-1)/36 ; ?>px" <?php foreach ($evenements as $evenement) { if ( (strtotime($evenement['even_datehorairedebut'])>= $j)&&(strtotime($evenement['even_datehorairedebut'])< $j+86400) ) { $taille = (timetosec(substr($evenement['even_datehorairefin'],11,8))-timetosec(substr($evenement['even_datehorairedebut'],11,8)))/36 ; echo '><input style="height:'.$taille.'px;top:0px;" class="waves-effect waves-light btn" type="button" value="'.$evenement['even_nom'].'

 '.substr($evenement['even_datehorairedebut'],11,5).' - '.substr($evenement['even_datehorairefin'],11,5).'" onclick='.base_url().'index.php/programme/detail/'.$evenement['even_id'].'/' ; } } $compt= true; echo '></td>' ; } } ?> </tr> <?php } ?> </tbody> </table> <?php }?>
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51 <table class="bordered centered"> <thead> <tr> <th></th> <th>vendredi 08 juin</th> <th>samedi 09 juin</th> <th>dimanche 10 juin</th> </tr> </thead> </tbody> <tr> <td style="height:100px;vertical-align:top;">08:00</td> <td rowspan="10" height="1000px" > <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe A

 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/1/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe B

 10:15 - 12:15" onclick=http://localhost/aerauto/index.php/programme/detail/2/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe C

 13:30 - 15:30" onclick=http://localhost/aerauto/index.php/programme/detail/3/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste Groupe D

 15:45 - 17:45" onclick=http://localhost/aerauto/index.php/programme/detail/4/> </td> <td rowspan="10" height="1000px" > <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste petite finale

 15:15 - 17:15" onclick=http://localhost/aerauto/index.php/programme/detail/5/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross Groupe A

 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/7/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross Groupe B

 10:15 - 12:15" onclick=http://localhost/aerauto/index.php/programme/detail/8/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Course de voilier miniature

 13:00 - 15:00" onclick=http://localhost/aerauto/index.php/programme/detail/10/> </td> <td rowspan="10" height="1000px" > <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture piste finale

 13:00 - 15:00" onclick=http://localhost/aerauto/index.php/programme/detail/6/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Tournoi Voiture cross finale

 15:45 - 17:45" onclick=http://localhost/aerauto/index.php/programme/detail/9/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Concours de voltige 

 10:00 - 12:00" onclick=http://localhost/aerauto/index.php/programme/detail/11/> <input style="height:200px;top:0px;" class="waves-effect waves-light btn" type="button" value="Concours de maquettes

 08:00 - 10:00" onclick=http://localhost/aerauto/index.php/programme/detail/12/> </td> </tr><tr> <td style="height:100px;vertical-align:top;">09:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">10:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">11:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">12:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">13:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">14:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">15:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">16:00</td> </tr><tr> <td style="height:100px;vertical-align:top;">17:00</td> </tr> </tbody> </table>
soit l'image suivante :
Voici le problème j'aimerai ordonner maintenant mes événements afin que les horaires correspondent a ma première colonne.
Merci de votre attention,
En espérant que vous pourrez m'aider,
Roiser
Partager