implementado va mas o menos asi:
Código PHP:
if ($foto=="paginas/".$id.".jpg"){
$st=$foto;
}
elseif ($foto=="paginas/".$id.".pdf"){
$st=$foto;
}
elseif ($foto=="paginas/".$id.".xls"){
$st=$foto;
}
elseif ($foto=="paginas/".$id.".doc"){
$st=$foto;
}
elseif ($foto=="paginas/".$id.".ppt"){
$st=$foto;
};
$res = explode(".", $st);
$st=$foto;
$img=paginas/".$id.".jpg;
if (file_exists($st) and $st==$img){
$n="";
$s="<img src=".$st." height='111' width='147'/>";
}
elseif (file_exists($st) and $st!=$img){
$n="";
$s=$st;}
pero no coge ningun valor incluyendo las 2 respuestas