par
alex288 » 18 août 2008, 19:17
je suis capable d`afficher l`image de la base de donnee mais quand je veux afficher ses informations lies a une autre table, ca m`affiche l`erreur suivante:
Champ: 'img_id' dans where clause est ambigu
Table image (img_id, img_nom, img_taille, img_type, img_blob)
table produit (ref_produit, description, titre, prix, img_id)
fichier apercu.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.ref_produit, produit.titre, produit.description FROM image, produit WHERE img_id = ".$id;
?>
fichier affichage.php
<?php
$db = mysql_connect("localhost","root",""); // connexion a la base de donnee
$ret = mysql_select_db("boutique",$db) or die (mysql_error ()); // selection de la base de donnee
//$ref_produit = $_POST["ref_produit"] ;
$req = "SELECT image.img_nom, image.img_id FROM image ORDER BY image.img_nom";
//$req = "SELECT image.img_nom, image.img_id, produit.ref_produit, produit.titre, produit.description, produit.prix FROM image, produit where image.img_id = produit.img_id ORDER BY image.img_nom";
$ret = mysql_query ($req) or die (mysql_error ());
//$ret = mysql_query ($req2) or die (mysql_error ());
while ( $col = mysql_fetch_row ($ret) )
{
echo "<a href=\"apercu.php?id=".$col[1].
"\">".$col[0]."</a><br /> ";
//echo "Details:";
}
?>
merci pour votre aide
je suis capable d`afficher l`image de la base de donnee mais quand je veux afficher ses informations lies a une autre table, ca m`affiche l`erreur suivante:
[b]Champ: 'img_id' dans where clause est ambigu[/b]
Table image (img_id, img_nom, img_taille, img_type, img_blob)
table produit (ref_produit, description, titre, prix, img_id)
[u]fichier apercu.php[/u]
[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.ref_produit, produit.titre, produit.description FROM image, produit WHERE img_id = ".$id;
?>[/php]
[u]fichier affichage.php[/u]
[php]<?php
$db = mysql_connect("localhost","root",""); // connexion a la base de donnee
$ret = mysql_select_db("boutique",$db) or die (mysql_error ()); // selection de la base de donnee
//$ref_produit = $_POST["ref_produit"] ;
$req = "SELECT image.img_nom, image.img_id FROM image ORDER BY image.img_nom";
//$req = "SELECT image.img_nom, image.img_id, produit.ref_produit, produit.titre, produit.description, produit.prix FROM image, produit where image.img_id = produit.img_id ORDER BY image.img_nom";
$ret = mysql_query ($req) or die (mysql_error ());
//$ret = mysql_query ($req2) or die (mysql_error ());
while ( $col = mysql_fetch_row ($ret) )
{
echo "<a href=\"apercu.php?id=".$col[1].
"\">".$col[0]."</a><br /> ";
//echo "Details:";
}
?>[/php]
merci pour votre aide