salut,
je suis capable d`afficher l`image de la base de donnee mais j`arrive pas a afficher ses informations lies a une autre table ( titre, prix, description).
Table image (img_id, img_nom, img_taille, img_type, img_blob).
table produit (ref_produit, description, titre, prix, img_id).
merci d`avance pour votre aide[/code]
je suis capable d`afficher l`image de la base de donnee mais j`arrive pas a afficher ses informations lies a une autre table ( titre, prix, description).
Table image (img_id, img_nom, img_taille, img_type, img_blob).
table produit (ref_produit, description, titre, prix, img_id).
Code:
fichier apercu.php
<?php
if ( isset($_GET['id']) )
{
$id = intval ($_GET['id']);
$db = mysql_connect("localhost","root","");
$ret = mysql_select_db("boutique",$db) or die (mysql_error ());
$req = "SELECT image.img_id, image.img_type, image.img_blob, produit.img_id, produit.ref_produit, produit.titre, produit.description FROM image INNER JOIN produit WHERE image.img_id = produit.img_id and image.img_id = ".$id;
$ret = mysql_query ($req) or die (mysql_error ());
$col = mysql_fetch_row ($ret);
if ( !$col[0] )
{
echo "Id d'image inconnu";
}
else
{
header ("Content-type: ".$col[1]);
echo $col[2] ;
echo $col[4];
echo $col[5];
echo $col[6];
}
}
else
{
echo "Mauvais id d'image";
}
?>
Code:
fichier affichage.php
<?php
$db = mysql_connect("localhost","root","");
$ret = mysql_select_db("boutique",$db) or die (mysql_error ());
$req = "SELECT image.img_nom, image.img_id FROM image ORDER BY image.img_nom";
$ret = mysql_query ($req) or die (mysql_error ());
while ( $col = mysql_fetch_row ($ret) )
{
echo "<a href=\"apercu.php?id=".$col[1].
"\">".$col[0]."</a><br /> ";
}
?>