Hey there,
I need to write up a database query wherein the data extracted from the table in one query is used to build, then execute another query. I made an attempt to nest the second query in a loop within the loop of the initial query, but it failed. Nesting loops probably also isn't the most efficient way to do it. Below is an example of the code I used so you can see what I mean.
$db_query_str = "SELECT sid, cid FROM $db_tbl_sced WHERE uid = $db_data_pnt_user[uid]";
$db_query_pnt_sced = db_query($db_query_str, $db_conn_pnt);
while ($db_data_pnt_sced = mysql_fetch_array($db_query_pnt_sced)) {
$db_query_str = "SELECT hid, title, body FROM $db_tbl_hmwrk WHERE sid = $db_data_pnt_sced[sid]";
$db_query_pnt_hmwrk = db_query($db_query_str, $db_conn_pnt);
while($db_data_pnt_hmwrk = mysql_fetch_array($db_query_pnt_hmwrk)) {
echo $db_data_pnt_hmwrk[title];
}
}
Sort of get the idea? I searched the forum and found some relevant posts. Something about a "join" caught my eye, but I'm a bit confused. If someone could please explain to me how I might go about executing a query like the one above I'd greatly appreciate it.
Thanks in advance
--ben