I want to do a query, and for each row in that query, do another query based on an attribute value (foreign key) in that row. I can't get it to work, and I am wondering if this is possible??
code looks something like this
any comments, hints or tips on how to solve this, please?
code looks something like this
Code:
$query = "SELECT `id`, `name`, `foreign_key` FROM `the_table`";
$result = mysql_query($query) or die('Query failed: ' . mysql_error());
while ($row = mysql_fetch_assoc($result)) {
.....
$query2 = "SELECT `this`, `that` FROM `table2` WHERE `thing` = $row['foreign_key']";
$result2 = mysql_query($query2) or die('Query failed: ' . mysql_error());
while ($row2 = mysql_fetch_assoc($result2)) {
.......
}
mysql_free_result($result2);
}
any comments, hints or tips on how to solve this, please?






