Ver Mensaje Individual
  #24 (permalink)  
Antiguo 08/10/2008, 11:23
patok
 
Fecha de Ingreso: octubre-2008
Mensajes: 24
Antigüedad: 15 años, 7 meses
Puntos: 0
Respuesta: Ver imagenes almacenadas en sybase con php

Hola a todos, solo para decirles que ya pude hacerlo, gracias KORG1988 y CARLOJAS por su valioso aporte, y mi contribucion a este foro sera el dejar todo el codigo con el cual si me funciona......

Archivo odbc.php
Código PHP:
<?php 
$dsn
="Tu_DSN"
$usuario="Tu_Usuario";
$clave="Tu_Clave";
$conexion=odbc_connect($dsn$usuario$clave);

if (!
$conexion){
    
    exit(
"Problema de conexion con la base de datos, Intentelo mas tarde");
}    
?>
Archivo Inicial.htm
Código HTML:
<HTML>
<HEAD>
<TITLE>HOLA MUNDO</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="CENTER"><FONT COLOR="RED"> MEDIC S.A. DE C.V.</FONT></H1>
<CENTER>
<FORM ACTION="Sql.php" METHOD="POST">
ESCRIBIR BC DEL PRODUCTO:
<input type="text" size="20" maxlength="50" name="BuC" >
<INPUT TYPE="submit" Name="Busca" value="Buscar Producto">
</FORM>
<table border=3 cellspacing=1 cellpadding=1>
<tr>
<td>NOMBRE DEL PRODUCTO:</td><td><input type="text" size="50" maxlength="50" name="Nom" 
value="" readonly="yes" ></td>
</tr>
<tr>
<td>DESCRIPCION DEL PRODUCTO:</td><td><TEXTAREA name="Cod" ROWS="5" COLS="50" readonly="yes" >
</TEXTAREA></td>
</tr>
<tr>
<td>PRECIO DEL PRODUCTO:</td><td><input type="text" size="20" maxlength="25" name="Prec" readonly="yes" 
value="" ></td>
</tr>
<tr>
<td>FOTOGRAFIA DEL PRODUCTO:</td><td><input type="text" size="20" maxlength="25" name="Foto" readonly="yes" ></td>
</tr>
</table>
</CENTER>
</BODY>
</HTML> 
Archivo Sql.php
Código PHP:
<?PHP
    
include("odbc.php");
    
$valor $_POST['BuC'];
    
$sql "select Producto.BC as BC, Producto.Codigo as Codigo, Producto.Descripcion as Descripcion, 
    Producto.Precio as Precio, PLUProducto
    from Producto
    where BC = '$valor'"
;
    
$result=odbc_exec($conexion,$sql)or die(exit("Error en odbc_exec"));
    
$plu odbc_result($result,"PLUProducto");
?>
<HTML>
<HEAD>
<TITLE>HOLA MUNDO</TITLE>
</HEAD>
<BODY>
<H1 ALIGN="CENTER"><FONT COLOR="RED">ELECTROLAB MEDIC S.A. DE C.V.</FONT></H1>
<H2 ALIGN="CENTER">RESULTADO DE LA BUSQUEDA</H2>
<CENTER>
<table border=3 cellspacing=1 cellpadding=1 bgcolor="blue">
<tr>
<td>NOMBRE DEL PRODUCTO:</td><td><input type="text" size="50" maxlength="50" name="Nom" 
value=<?php print odbc_result($result,2);?> ></td>
</tr>
<tr bgcolor="red">
<td>DESCRIPCION DEL PRODUCTO:</td><td><TEXTAREA name="Cod" ROWS="5" COLS="50" >
<?php print odbc_result($result,3);?>  </TEXTAREA></td>
</tr>
<tr bgcolor="yellow">
<td>PRECIO DEL PRODUCTO:</td><td><input type="text" size="20" maxlength="25" name="Prec" 
value=<?php print odbc_result($result,4);?> ></td>
</tr>
<tr bgcolor="brown">
<td>FOTOGRAFIA DEL PRODUCTO:</td><td><img src="blob.php?id=<?php echo $plu;?>" /></td>
</tr>
</table>
</CENTER>
<BR>
<BR><center>
<A href="inicial.htm"><INPUT TYPE="Button" value="Volver a Preguntar"></A></center>
</BODY>
</HTML>
y por ultimo pero no menos importante el archivo blob.php con el cual muestro la imagen:
Código PHP:
<?php
    
include("odbc.php");
    
$Query $_GET['id'];
    
$Query_ID odbc_exec($conexion" SELECT Foto FROM Producto_Foto where ProductoID = '$Query'");  
    if (
$Query_ID) {
    
odbc_longreadlen($Query_ID131072);
    
odbc_binmode($Query_ID,ODBC_BINMODE_PASSTHRU);
    
header("Content-type: image/JPEG");
    
$Images odbc_result($Query_ID1);
    }
?>
Gracias por su ayuda y a compratir se ha dicho, espero este codigo le ayude a alguien, saludos a todos.......