Précédent   Forum des professionnels en informatique > PHP > Langage > Débuter
Débuter Forum d'entraide pour débuter en PHP. Avant de poster -> Cours PHP, FAQ PHP, Outils PHP, etc.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 15/03/2011, 12h35   #1
Membre à l'essai
 
Inscription : avril 2008
Messages : 140
Détails du profil
Informations forums :
Inscription : avril 2008
Messages : 140
Points : 21
Points : 21
Par défaut mettre des div et span à la place de table et tr

Bonjour,
Voici mon problème j'ai le code ci dessous avec des tables th et tr et cependant
je veux le structurer avec des div et span.

le premier ci-dessous marche bien
Code :
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
<div id="calendrier2">
    <table>
        <tr>
            <th><span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb - 1; ?>&year=<?php echo $this->year; ?>"><<</a></span></th>
            <th colspan="5" class="headcal"><?php echo($this->month.' '.$this->year);  ?></th>
            <th><span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb + 1; ?>&year=<?php echo $this->year; ?>">>></a></span></th>
            <th><a href="#"><img  id="calendrier" src="<?php echo $this->baseUrl();?>/images/icones_js_calendrier/annee.jpg"></a></th>      
        </tr>
        <?php
            echo('<tr>');
            for($i = 1; $i <= 7; $i++){
                echo('<th>'.$this->daytab[$i].'</th>');
            }
            echo('</tr>');
            for($i = 1; $i <= count($this->calendar); $i++) {
                echo('<tr>');
                for($j = 1; $j <= 7 && $j-$this->firstday+1+(($i*7)-7) <= $this->nbdays; $j++){
                    if($j-$this->firstday+1+(($i*7)-7) == date("j") && $this->monthnb == date("n") && $this->year == date("Y")) echo('<th class="current" style="width:107px;height:50px;background-color:silver;"><div style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;" id="calendrier">'.$this->calendar[$i][$j].'</div></th>');
                    else echo('<th style="width:107px;height:50px;background-color:silver;"><div style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;">'.$this->calendar[$i][$j].'</div></th>');
                }
                echo('</tr>');
            }
        ?>
    </table>
</div>




Alors que,celui si me donne une erreur à la ligne 18arse error: parse error in ligne18

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<div id="calendrier">
<div class="calendrier_div_mois_entete">
	<div>
		<span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb - 1; ?>&year=<?php echo $this->year; ?>"><<</a></span>
		<span><?php echo($this->month.' '.$this->year);  ?><?php echo($this->month.' '.$this->year);  ?></span>
		<span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb + 1; ?>&year=<?php echo $this->year; ?>">>></a></span>
	</div>
	<div>
		<?php for($i = 1; $i <= 7; $i++){?>
     		<span><?php echo $this->daytab[$i];?></span>
     	<?php }?>	
	</div>
	<div class="calendrier_div_mois_contenu">
	<?php for($i = 1; $i <= count($this->calendar); $i++) {?>
                <span>
                <?php for($j = 1; $j <= 7 && $j-$this->firstday+1+(($i*7)-7) <= $this->nbdays; $j++){
                    if($j-$this->firstday+1+(($i*7)-7) == date("j") && $this->monthnb == date("n") && $this->year == date("Y")) ?> <span class="current" style="width:107px;height:50px;background-color:silver;"><span style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;" id="calendrier"><?php echo $this->calendar[$i][$j];?></span></span>');
                    <?php else ?><span style="width:107px;height:50px;background-color:silver;"><div style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;"><?php echo $this->calendar[$i][$j];?></span></span>');
                <?php }?>	
                </span>
    <?php }?> 
	</div>
</div>
</div>


Aidez moi svp !!Comment faire pour que mon deuxièmz codz marche?
sajodia est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/03/2011, 12h52   #2
Modérateur
 
Avatar de Benjamin Delespierre
 
Benjamin Delespierre
Développeur Web
Inscription : février 2010
Messages : 2 984
Détails du profil
Informations personnelles :
Nom : Benjamin Delespierre
Âge : 24
Localisation : France

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : février 2010
Messages : 2 984
Points : 5 014
Points : 5 014
Hello

Citation:
Voici mon problème j'ai le code ci dessous avec des tables th et tr et cependant
je veux le structurer avec des div et span.
Si l'affichage des données est bien un tableau, l'usage du tag table est tout à fait justifié, il ne faut surtout pas chercher à mettre des div systématiquement.

Pour ton problème de syntaxe: tu n'as pas mis de bloc sous l'instuction if...
C'est comme ça que tu aurais dû faire:
Code :
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
 
<div id="calendrier">
<div class="calendrier_div_mois_entete">
	<div>
		<span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb - 1; ?>&year=<?php echo $this->year; ?>"><<</a></span>
		<span><?php echo($this->month.' '.$this->year);  ?><?php echo($this->month.' '.$this->year);  ?></span>
		<span class="linkcal"><a href="ajaxaffiche?month=<?php echo $this->monthnb + 1; ?>&year=<?php echo $this->year; ?>">>></a></span>
	</div>
	<div>
		<?php for($i = 1; $i <= 7; $i++){?>
     		<span><?php echo $this->daytab[$i];?></span>
     	<?php }?>	
	</div>
	<div class="calendrier_div_mois_contenu">
	<?php for($i = 1; $i <= count($this->calendar); $i++) {?>
                <span>
                <?php for($j = 1; $j <= 7 && $j-$this->firstday+1+(($i*7)-7) <= $this->nbdays; $j++){
                    if($j-$this->firstday+1+(($i*7)-7) == date("j") && $this->monthnb == date("n") && $this->year == date("Y")) { ?> <span class="current" style="width:107px;height:50px;background-color:silver;"><span style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;" id="calendrier"><?php echo $this->calendar[$i][$j];?></span></span>');
                    <?php } else { ?><span style="width:107px;height:50px;background-color:silver;"><div style="width:40px;height:20px;background-color:white;float:left;margin-top:-20px;"><?php echo $this->calendar[$i][$j];?></span></span>');
                <?php } }?>	
                </span>
    <?php }?> 
	</div>
</div>
</div>
Veille à indenter correctement de sorte que le code source ne dépasse pas la largeur de l'écran, ça facilitera la lisibilité.
Utilise aussi, si tu peux, les formes abrégées:
Code :
1
2
3
4
5
6
7
8
 
<div>
<?php if ($a != 'peter'): ?>
  <span>Say hello to <?=$a?></span>
<?php else: ?>
  <span>Say hello to peter</span>
<?php endif; ?>
</div>
__________________
A la recherche d'un framework MVC facile a prendre en main ? Essayez Axiom
Nouveau: la référence d'Axiom est disponible sur GitHub (je la peaufine en ce moment même).

Un problème correctement identifié est à moitié résolu, évitez de poster l'intégralité de votre code avec pour seule explication "ça ne marche pas...".
Pour identifier correctement vos problèmes PHP, utilisez la gestion des erreurs et xdebug.

Les boutons et existent, servez-vous en
Benjamin Delespierre est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 15/03/2011, 14h14   #3
Membre à l'essai
 
Inscription : avril 2008
Messages : 140
Détails du profil
Informations forums :
Inscription : avril 2008
Messages : 140
Points : 21
Points : 21
Super!!Merci beaucoup ça marche
sajodia est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 21h22.


 
 
 
 
Partenaires

Hébergement Web