Récupérer et afficher champ type image [php]

Fermé
mymy2002 - 30 déc. 2009 à 16:08
 mymy2002 - 4 janv. 2010 à 11:56
Bonjour,
Je voudrais récupérer une image stockée dans une bdd sql server sur un serveur distant. Le type du champ est image. Voici le code que j'ai fait, je ne sais plus quoi faire :( , j'arrive à me connecter à la base mais pas à afficher l'image :

showimage.php :
[code]<?php

$ID = $_POST['produit_id'];
//CONNEXION AU SERVEUR
$CONN = mssql_connect("XXXXXXXX","sa","XXXXXXXX") OR DIE('ERREUR DE CONNEXION');
//SÉLECTION DE LA BASE DE DONNÉES
$DB= MSSQL_SELECT_DB('catalogue',$CONN) OR DIE('ERREUR DE SÉLECTION DE LA BASE DE DONNÉES');
//REQUÊTE QUI VA RÉCUPÉRER L'IMAGE
$RESIMG = MSSQL_QUERY("SELECT * FROM PHOTOTEQUE P, PRODUIT_IMG I WHERE P.PHOTOTEQUE_ID = I.PHOTOTEQUE_ID AND PRODUIT_ID ='".$ID."' and produit_img_position='1'");
$ROW = mssql_fetch_assoc($RESIMG);
$IMAGE = $ROW['phototeque_image'];
//AFFICHAGE DE L IMAGE
header("Content-type: image/jpeg");
echo $IMAGE;

?>/code


ls_prod.php :
[code]<?php
//Connexion au serveur
$conn = mssql_connect("XXXXXXX","sa","XXXXXXX") or die('Erreur de connexion');
//Sélection de la base de données
$db= mssql_select_db('catalogue',$conn) or die('Erreur de sélection de la base de données');
?>
<html>
<head>
<title>Récupération de données
</title>
<link rel="stylesheet" type="text/css" href="styleDevis.css" />
</head>
<body>
<div class="bandeau"> Fiche du Produit
</div>
<div class="contenu">
<?php
$req3 = ("Select categorie_nom, famille_nom, marque_nom from categorie, famille, marque, produit where categorie.categorie_id = produit.produit_categorie and famille.famille_id=produit.produit_famille and marque.marque_id=produit.produit_marque and produit_id ='".$_POST['produits']."'");
$req = "SELECT * FROM produit where produit_id ='".$_POST['produits']."' ORDER BY produit_nom";
$req4 = "SELECT * from caracteristique, descriptif where caracteristique.caracteristique_id = descriptif.specification_id and produit_id='".$_POST['produits']."'";
$res4 = mssql_query($req4);
$row4 = mssql_fetch_array($res4);
$res = mssql_query($req);
$row= mssql_fetch_array($res);
$res3 = mssql_query($req3);
$row3= mssql_fetch_array($res3);
?>
<center>
<img src=showimage.php?produit_id=<?php echo $row['produit_id'];?> alt="im" />
</center> <br />
<table colspan ="100%">
<tr>
<td colspan="98%" align="center" color="mintcream"><b>
<?php echo $row['produit_nom']; ?></b></td>
<td><i>Référence :
<?php echo $row['produit_ref']; ?></i></td>
</tr>
<tr>
<td colspan="50%"><i>Catégorie :
<?php echo $row3['categorie_nom']; ?></i></td>
<td colspan="25%"><i>Famille :
<?php echo $row3['famille_nom'];?></i></td>
<td colspan="25%"><i>Marque :
<?php echo $row3['marque_nom'];?></i></td>
</tr>
<tr>
<td colspan="100%">
<?php echo $row['produit_caraPrincipal'];?></td>
</tr>
<tr>
<td colspan="100%">
<ul><br />
<?php while($row4){ echo '<li><b>'.$row4['caracteristique_nom'].'</b> :   '.$row4['descriptif_description'].'</li>'; $row4 = mssql_fetch_array($res4);} ?>
</ul></td>
</tr>
<tr>
<td colspan="100%">
<?php echo $row['produit_commentaire']; ?></td>
</tr>
</table>
</div>
</body>
</html>/code
A voir également:

1 réponse

up!
0