Page 1 sur 1

Condition else

Posté : 11 avr. 2006, 16:15
par Photographiquement Vôtre
Bonjour,

Quand je met que la condition if cela marche mais quand je met la condition else cela ne marche pas.

D'où cela peut il venir.

Merci pour votre aide
<?php 


		list($width, $height, $type, $attr) = getimagesize("Photos/{$data['Ref_Image']}");

	
		if ($width > $height);

			{
  
			echo "<a href=photos_vue.php?Pos={$data['Id']}><img src=Photos/{$data['Ref_Image']} center width=150 height=100>";
	
			}

		else

			{

			echo "<a href=photos_vue.php?Pos={$data['Id']}><img src=Photos/{$data['Ref_Image']} center width=100 height=150>";	
				
			}	

?>

Posté : 11 avr. 2006, 16:16
par charabia
if ($width > $height)
Le ";" doit être supprimé.

Posté : 11 avr. 2006, 16:17
par zigz4g
Salut

Enleve peut etre le point virgule a la fin du if
 if ($width > $height); //<<<-----

Posté : 11 avr. 2006, 16:19
par Photographiquement Vôtre
Désolé je commence à fatiguer.

Je vais aller me coucher

Posté : 11 avr. 2006, 18:10
par albat
Je me permets de te suggérer l'écriture suivante, un brin plus légère...
echo "<a href='photos_vue.php?Pos=".$data['Id']."'>";
echo "  <img src='Photos/".$data['Ref_Image']."' ".($width>$height ? "width='150' height='100'" : "width='100' height='150'").">";
echo "</a>";
Au fait, c'est quoi, le center qui traîne dans ta balise <img /> ??? :shock:

Posté : 11 avr. 2006, 18:14
par zigz4g
De meme pour width et height ???
Ce ne devrait pas etre dans un attribut style ?

Posté : 11 avr. 2006, 18:24
par albat
ce serait en effet plus valide. ;)