Use Result to find in other table and make new result

Hello

I have
Two tables

  • supliers
    = contains : the names of my supliers
  • Supliers_data
    = contains : the same names and adresses
    And 1 Form

i already have made my 1 result,
Like you se he contact my database and put A echo with A suppliers name,
How can i use this result to find the same name in an other table and give the result in the same echo…

Image ‘explain’ > http://pockta.com/help.png

Current

<?php
$query  = "SELECT suplier FROM supliers";
$result = mysql_query($query);

while($row = mysql_fetch_row($result))
{
    $suplier= $row[0];
            echo "$suplier" ;
}
?>

You need to make join query:
[php]$query = “SELECT supliers.suplier, address FROM supliers LEFT JOIN supliers_data ON supliers.suplier = supliers_data.suplier”;[/php]

and then within loop, you will have:
[php]$suplier= $row[0];
$address= $row[1];[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service