Jump to content

Help with a Query


JSHINER

Recommended Posts

I am wondering how using the following:

 

while($row = mysql_fetch_array($result)){ echo $row['STUFF']; }

 

How could create another query within EACH result so I could run a query based on $row['STUFF'].

 

Because I have two databases, one which contains the $row['STUFF'] and another that contains what I am looking for.

 

So lets say I want the name of a person that matches $row['STUFF'] - How can I go about doing this?

Link to comment
https://forums.phpfreaks.com/topic/49814-help-with-a-query/
Share on other sites

Hi

 

<?php

mysql_select_db("db1");
$result = mysql_query("SELECT....");
while ($row = mysql_fetch_array($result))
{
  $stuff = $row['STUFF'];
  mysql_select_db("db2");
  $result2 = mysql_query("SELECT .. WHERE stuff='$stuff';");
  while ($row2 = mysql_fetch_array($result2))
  {
      echo $row2['FOOBAR'];
  }
}

 

Should work like,  i think

 

Cheers,

tdw

Link to comment
https://forums.phpfreaks.com/topic/49814-help-with-a-query/#findComment-244338
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.