<?php
$query = "SELECT id FROM table";
$result = mysql_query($query);
if ($result) {
while ($r = mysql_fetch_array($result) {
$id = $r["id"];
$query2 = "SELECT * FROM otherTable where id = '$id'";
$result2 = mysql_query($query2);
if ($result) {
while ($r2 = mysql_fetch_array($result2) {
$colfrom2ndtable = $r2["name"];
}
}
}
}
?>
Regards....
Mark
Another way is to put the results of $result in an array. Then (outside
the while-loop) do a for-loop and wlak through the results in the array
and use the id.
John Victor wrote:
In my php page I'm using a mysql database. I want to run a query on a
table, then run a second query on the results returned from the first query.
In mysql this would be the same as running a query on a table to create a
view, and then running a query on the resulting view. What is the php
equivalent of this?
Thanks.