techker Posted July 20, 2010 Share Posted July 20, 2010 Hey guys i have a catalogue im working with and on my front page of my website i would like to put recent order.. So i need to grab info from 3 database's.. first is the order details tblorderDetails to grab the IDProduct then i need the tblProduct for the IDImage( product image) then last tblImage for the image file and name.. can anybody help me with this query? Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/ Share on other sites More sharing options...
techker Posted July 20, 2010 Author Share Posted July 20, 2010 Ok so i have been messing arround and found this to show me the Imgae id $sql = 'SELECT c . NoCommande , c . UName , c . Etat , c . DateCommande , cd . Quantite , cd . Rabais , cd . Prix , p . description , p . DescriptionCourte , p . IDImage ' . ' FROM tblCommande AS c ' . ' INNER JOIN tblCommandeDetail AS cd ON cd . NoCommande = c . NoCommande ' . ' INNER JOIN tblProduits AS p ON p . IDProduit = cd . IDProduit ' . ' INNER JOIN tblImages AS t ON t . IDImage = p . IDImage ' . ' WHERE c . NoCommande = 30 LIMIT 0, 30 '; NoCommande UName Etat DateCommande Quantite Rabais Prix description DescriptionCourte IDImage i got the image id!but how do i now go in IDImages to get the location? Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1088546 Share on other sites More sharing options...
fenway Posted July 23, 2010 Share Posted July 23, 2010 Huh? Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090338 Share on other sites More sharing options...
techker Posted July 23, 2010 Author Share Posted July 23, 2010 i need to show the image not the id.cause this query gets all the image id's Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090424 Share on other sites More sharing options...
.josh Posted July 23, 2010 Share Posted July 23, 2010 so tell it to show you the image instead. Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090426 Share on other sites More sharing options...
gizmola Posted July 23, 2010 Share Posted July 23, 2010 techker: Where is the image? Is it on the filesystem or a blob in the database? What is the structure of the tblImages table? As good as fenway is, he can't read your mind. Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090427 Share on other sites More sharing options...
techker Posted July 23, 2010 Author Share Posted July 23, 2010 ok this is tblimages Field Type Collation Attributes Null Default Extra Action IDImage bigint(20) No auto_increment Image blob BINARY Yes NULL Nom varchar(50) latin1_swedish_ci No Taille float No Fichier tinyint(1) No commande details NoCommande mediumint(9) No IDProduit bigint(9) No Quantite int(11) No Rabais float No Prix float No tblProduits Field Type Collation Attributes Null Default Extra Action IDProduit bigint(20) No auto_increment IDProduit Access bigint(20) Yes 0 IDCatalogue smallint(6) No IDCategorie mediumint(9) No IDFabriquant mediumint(9) No SkuFabriquant varchar(25) latin1_swedish_ci No DescriptionCourte varchar(40) latin1_swedish_ci No Description text latin1_swedish_ci No Prix decimal(12,6) Yes NULL PrixCoutant double Yes NULL IDImage bigint(20) No QuantiteDisponible int(11) Yes NULL LinkExterne varchar(300) latin1_swedish_ci Yes NULL PrixRegulier float(12,6) Yes NULL Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090437 Share on other sites More sharing options...
gizmola Posted July 24, 2010 Share Posted July 24, 2010 Ok, so basically you need a script that queries your tblimages by IDImage, gets the blob data, sets the headers and returns the data. You need to set the mimetype to match the image. I'm not sure where you can derive that based on your table structure, but perhaps it's in the name, and you can get it from the filename extension. Maybe you will call the script getImage.php So in your html output you would have the img tag echo ""; Your getImage.php script would be something similar to this: // have to setup database connection before this $id = (int)$_GET['id']; $result = mysql_query("SELECT Image, Nom FROM tblimages WHERE IDImage = $id"); $row = mysql_fetch_assoc($result); header('Content-Length: '.strlen($row['Image'])); header("Content-type: image/jpeg"); // note i hardwired this to jpeg, but should detect and set right mimetype for whatever image type it is echo $row['Image']; exit(); Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090471 Share on other sites More sharing options...
techker Posted July 24, 2010 Author Share Posted July 24, 2010 i think i just clicked..i have a file called img.php so basicly i inlude the echo image id in the link echo "<img src='getImage.php?id=$IDImage'>"; yap i got..thx!! Quote Link to comment https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090477 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.