Précédent   Forum des professionnels en informatique > PHP > Langage
Langage Forum sur le langage PHP, la POO, les conventions, la sécurité, etc. Avant de poster : FAQ Langage, toutes les FAQ PHP, cours langage et sources PHP
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 08/01/2011, 09h27   #1
Candidat au titre de Membre du Club
 
Homme laurent
Inscription : décembre 2005
Messages : 93
Détails du profil
Informations personnelles :
Nom : Homme laurent

Informations forums :
Inscription : décembre 2005
Messages : 93
Points : 14
Points : 14
Par défaut condition if dans result

bonjour
je cherche à poser une condition if dans un result voici le bout de code , en fait je ne connais pas la syntaxe ... je suis débutant
merci LJ
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$result.="<table width='100%' border='$bordersize_graph' bordercolor='$color_graph' cellspacing='0' cellpadding='0'>
        <tr>
          <td><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
            <tr>
 
	if ($CO2_fioul == 0) {
	     <td width='20%'><div align='center'><font color='#d43c0f'>".$fioul_perc."%</font></div></td>
	}
	elseif ($CO2_fioul == 1) {  }
 
              <td width='20%'><div align='center'><font color='#006600'>".$elec_perc."%</font></div></td>
              <td width='20%'><div align='center'><font color='#297fd0'>".$gaz_perc."%</font></div></td>
              <td width='20%'><div align='center'><font color='#FF6600'>".$avion_perc."%</font></div></td>
	      <td width='20%'><div align='center'><font color='#6367ba'>".$voit_perc."%</font></div></td>
              <td width='20%'><div align='center'><font color='#e3ac11'>".$train_perc."%</font></div></td>
            </tr>
cela me ramène une écriture du genre "
if (0 == 0) { } elseif (0 == 1) { }
"
laurent00 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/01/2011, 11h07   #2
Modérateur
 
Avatar de sabotage
 
Homme Vincent
Inscription : juillet 2005
Messages : 14 929
Détails du profil
Informations personnelles :
Nom : Homme Vincent

Informations forums :
Inscription : juillet 2005
Messages : 14 929
Points : 16 381
Points : 16 381
En deux étapes :
Code :
1
2
3
4
5
6
7
$result.="<table width='100%' border='$bordersize_graph' bordercolor='$color_graph' cellspacing='0' cellpadding='0'>
        <tr>
          <td><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
            <tr>";
 
	if ($CO2_fioul == 0) {
	     $result.= "<td width='20%'><div align='center'><font color='#d43c0f'>".$fioul_perc."%</font></div></td>";
sabotage est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/01/2011, 12h26   #3
Candidat au titre de Membre du Club
 
Homme laurent
Inscription : décembre 2005
Messages : 93
Détails du profil
Informations personnelles :
Nom : Homme laurent

Informations forums :
Inscription : décembre 2005
Messages : 93
Points : 14
Points : 14
Par défaut ok

oui mais comment j'enchaîne ... au niveau des <td> ..
LJ

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
$result.="<table width='100%' border='$bordersize_graph' bordercolor='$color_graph' cellspacing='0' cellpadding='0'>
        <tr>
            <td><table width='100%'  border='0' cellspacing='0' cellpadding='0'>
        <tr>";
 
	if ($CO2_fioul == 0) {
	 $result.="<td width='20%'><div align='center'><font color='#d43c0f'>".$fioul_perc."%</font></div></td>";}
	elseif ($CO2_fioul == 1) {  }
 
	if ($CO2_elec == 0) {
	 $result.="<td width='20%'><div align='center'><font color='#006600'>".$elec_perc."%</font></div></td>";}
	elseif ($CO2_elec == 1) {  }
 
 
              <td width='20%'><div align='center'><font color='#297fd0'>".$gaz_perc."%</font></div></td>
              <td width='20%'><div align='center'><font color='#FF6600'>".$avion_perc."%</font></div></td>
	      <td width='20%'><div align='center'><font color='#6367ba'>".$voit_perc."%</font></div></td>
              <td w
laurent00 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 08/01/2011, 14h47   #4
Candidat au titre de Membre du Club
 
Homme laurent
Inscription : décembre 2005
Messages : 93
Détails du profil
Informations personnelles :
Nom : Homme laurent

Informations forums :
Inscription : décembre 2005
Messages : 93
Points : 14
Points : 14
Par défaut réglé

c réglé merci
laurent00 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 18h07.


 
 
 
 
Partenaires

Hébergement Web