AHORA SI
Código PHP:
if (file_exists("imagen/".$id.".jpg")) {
$foto1="imagen/".$id.".jpg";
} elseif (file_exists("imagen/".$id.".pdf")) {
$foto1=$id.".pdf";
} elseif (file_exists("imagen/".$id.".doc")) {
$foto1=$id.".doc";
} elseif (file_exists("imagen/".$id.".xls")) {
$foto1=$id.".xls";
} elseif (file_exists("imagen/".$id.".ppt")) {
$foto1=$id.".ppt";
};
$img="paginas/".$id.".jpg";
if (file_exists($foto1) and $foto1==$img){
$n="";
$s="<img src=".$foto1." height='111' width='147'/>";
}
elseif (file_exists($foto1) and $foto1!=$img){
$n="";
$s=$foto1;}