Tu problema parece estar en esta linea:
Código PHP:
<img src="verimagen.php?id=<?= $fila['id'] ?>" width="154" height="150" />
La imagen esta bien asi... pero... el src significa source (fuente) y es de donde sacas la foto... por lo tanto no puedes hacerlo desde una url en donde tienes que cargar la pagina para procesarla y obtener datos...
Mi idea es esta:
NOTICIAS.PHP
Código PHP:
<?
include("VERIMAGEN.PHP");
$miImagen = new VerImagen();
$cols = 1;
if (isset ($_GET['cols']))
$cols = $_GET['cols'];
$resultado = mysql_query("SELECT * FROM foto");
$num = mysql_num_rows($resultado);
$filas = ceil($num/$cols);
?>
<table width="150" border="0" cellspacing="0" cellpadding="1">
<? for ($i=0; $i<$filas; $i++){ ?>
<tr>
<? for ($j=0; $j<$cols; $j++){ ?>
<td>
<?
if ($fila = mysql_fetch_array($resultado)){
$img = $miImagen->getImagen($fila['id']);
?>
<img src="<?= $img ?>" width="154" height="150" />
<?
}else{
echo(' ');
}
?>
</td>
<?
}
}
?>
</tr>
</table>
VERIMAGEN.PHP
Código PHP:
<?
class VerImagen{
function getImagen($id){
include("conexion.php");
conectarse();
$qry = "SELECT nombre_archivo, tipo, tamano FROM foto WHERE id='$id'";
$res = mysql_query($qry);
$archivo = mysql_fetch_array($res);
if ($archivo['tamano'] != ""){
$tipo = $archivo["tipo"];
$contenido = $archivo["tamano"];
}else{
$qry = "SELECT nombre_archivo, tipo, tamano FROM foto WHERE id='3'";
//echo($qry);
$res = mysql_query($qry);
$archivo = mysql_fetch_array($res);
$tipo = $archivo["tipo"];
$contenido = $archivo["tamano"];
}
mysql_close();
return ($tipo,$contenido);
}
}
?>