Jump to content

Recommended Posts

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?

 

Link to comment
https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1088546
Share on other sites

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               

       

 

 

Link to comment
https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090437
Share on other sites

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();

Link to comment
https://forums.phpfreaks.com/topic/208280-query-for-3-dbs/#findComment-1090471
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.