tengo una aplicacion en la cual muestro los datos de un articulo, entre ellos la referencia el nombre etc... y tengo un link que se llama "Ver Imagen", el cual me envia a una pagina llamada mostImagen.
****Pagina mostrarArti****
Esta pagina muestra los datos del articulo en una tabla y el link paar ver la imagen
Código PHP:
<?php
require_once('conexion.php');
$ref=$_POST["ref"];
$tip=$_POST["tipo"];
if(ref!=NULL)
{
$consulta="SELECT tipo FROM articulo WHERE refArticulo='$ref'";
$resp=mysql_query($consulta);
$dato=mysql_fetch_array($resp);
if($dato)
$tip=$dato["tipo"];
}
if($tip!=NULL)
{
if (!isset($pag))
$pag = 1; // $pg es la pagina actual
$cantidad=10; // cantidad de resultados por página
$inicial = $pag * $cantidad;
$result = mysql_query("SELECT COUNT(*) FROM articulo");
list($total) = mysql_fetch_row($result);
$tampag = 10;
$reg1 = ($pag-1) * $tampag;
$result = mysql_query("SELECT * FROM articulo WHERE tipo='$tip'
LIMIT $reg1, $tampag");
$sql="SELECT * FROM articulo WHERE tipo='$tip'";
$result=mysql_query($sql);
if (mysql_num_rows($result)){
echo "<table align='center' bgcolor= '#006699' cellpadding=10 cellspacing=2 border=1>"; // Comenzamos la tabla antes del ‘while’
echo "<tr><th>Referencia</th><th>Nombre</th><th>Talla</th><th>Color</th><th>Stock Max.</th><th>Stock Min.</th><th>Cant Disp</th><th>Precio Venta</th><th>Precio Compra</th><th>Imagen</th></tr>"; // Así escribimos la cabecera de la tabla
while ($row = @mysql_fetch_array($result))
{
$ref=$row["refArticulo"];
$name=$row["nombre"];
$talla=$row["talla"];
$color=$row["color"];
$smin=$row["cantMinDep"];
$smax=$row["cantMaxDep"];
$cant=$row["cantDisp"];
$pc=$row["precVenta"];
$pv=$row["precCompra"];
echo "<tr><td>$ref</td>"; // Comenzamos una fila (<tr>)
echo "<td>$name</td>";
echo "<td>$talla</td>";
echo "<td>$color</td>";
echo "<td>$smin</td>";
echo "<td>$smax</td>";
echo "<td>$cant</td>";
echo "<td>$pc</td>";
echo "<td>$pv</td>";
echo "<td><a href=mostImagen.php?id=$ref>Ver Imagen</a></td></tr>"; // [/SIZE][/SIZE]Acabamos una fila (</tr>)
}
echo "</table>"; // Fin de la tabla.
$total_paginas = ceil($total/$cantidad);
$anterior = $pag - 1;
$posterior = $pag+ 1;
$enlace="mostrarArti.php?pag=";
if ($pag>1)
echo "<a href=\"$enlace$anterior\">«</a> ";
else
echo "<b>«</b> ";
for ($i=1; $i<$pag; $i++){
echo "<a href=\"$enlace$i\">$i</a> ";
echo "<b>$pag</b> ";}
for ($i=$pag+1; $i<=$total_paginas; $i++)
echo "<a href=\"$enlace$i\">$i</a> ";
if ($pag<$total_paginas)
echo "<a href=\"$enlace$posterior\">»</a>";
else
echo "<b>»</b>";
}
}
else
echo"<script>alert ('Registro no encontrado en la Base de Datos');
</script>";
?>
esta pagina hace todo lo relacionado con la extraccion del registro de la imagen en la bd
Código PHP:
<?php
require_once('conexion.php');
$id = (isset($_GET["id"])) ;
$result = mysql_query("SELECT Imagen, tipoIm FROM articulo WHERE identificacion='$id'");
$Imagen=@mysql_result($res, 0, "Imagen");
$tipo=@mysql_result($res, 0, "tipoIm");
header("Content-Type:$tipo");
echo $Imagen;
?>
esta pagina se supone debe mostrar la foto
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Documento sin título</title> </head> <body> <img src="verFoto.php" height="100" width="120"> </body> </html>
Warning: Cannot modify header information - headers already sent by (output started at C:\AppServ\www\Almacen\menu\mostImagen.php:6) in C:\AppServ\www\Almacen\menu\mostImagen.php on line 11
Por favor espero haberme hecho entender, la verdad es que no tengo mucha experiencia en esto de las imagenes en mysql, y lo necesito con urgencia