Probleme avec if or et else

Résolu
loulounette -  
 loulounette -
Bonjour,
J'ai un script php qui liste tous les fichiers présents sur mon site, et les affiche avec des icones différentes selon les types. Mais pour le type image et htm/html, j'ai un problème : il m'affiche l'entrée avec la bonne icone, plus une autre entrée avec l'icone 'indefini'. Voilà la partie en cause de mon script :


$type = str_replace('.','',strstr($Entry, '.'));
		
if( $type == "gif" or $type == "jpg" or $type == "png")
{
			echo '<li><img src="images/images.gif"width="30"height="30">'.$Entry;

			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href ="telecharger.php?fichier='.$Entry.'&chemin='.$Directory.'">t&eacute;l&eacute;charger</a>';
			echo '&nbsp;&nbsp;&nbsp;<a href ="'.$Directory.'/'.$Entry.'">voir</a></li>';
}
if( $type == "html" or  $type == "htm")
{
			echo '<li><img src="images/htm.gif"width="30"height="30">'.$Entry;

			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href ="telecharger.php?fichier='.$Entry.'&chemin='.$Directory.'">t&eacute;l&eacute;charger</a>';
}
if( $type == "php")
{
			echo '<li><img src="images/php.gif"width="30"height="30">'.$Entry;

			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href ="telecharger.php?fichier='.$Entry.'&chemin='.$Directory.'">t&eacute;l&eacute;charger</a>';
}




						else{
			echo '<li><img src="images/fichier.gif"width="30"height="30">'.$Entry;
			echo '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href ="telecharger.php?fichier='.$Entry.'&chemin='.$Directory.'">t&eacute;l&eacute;charger</a></li>';
                }



Et le résultat :
http://tutoflash.e3b.org/test/listing.php
Configuration: Windows XP
Firefox 3.0.3
A voir également:
  • Probleme avec if or et else
  • X64 or x86 - <a href="https://forums.commentcamarche.net/forum/windows-7-124">Forum Windows 7</a>
  • Une famille en or powerpoint - <a href="https://forums.commentcamarche.net/forum/graphisme-22">Forum Graphisme</a>
  • Ruée vers l'or - Guide
  • If out - <a href="https://forums.commentcamarche.net/forum/materiel-systeme-2">Forum Matériel & Système</a>
  • Livre d'or hiwit - <a href="https://forums.commentcamarche.net/forum/webmaster-24">Forum Webmastering</a>

1 réponse

loulounette
 
J'ai trouvé : il fallait mettre elseif à la place de if.
0