I am having an issue with doing a query while looping through a result set. I do use a database abstraction layer written years ago by Frank Kromman...but not sure if that is causing the problem.
Here is an example of what is going on (I am typing this on the fly):
If I run the above, what I will get is the first field from $rs1 only. If I modified $sql2 to be "SELECT book, author from ..." then I would get the first 2 fields from $rs1. And of course, if I modify $sql2 to be "SELECT book, author, isbn FROM ..." I get the first 3 fields...
Obvious pattern, and probably a newbie issue...but I do not know what to do. In my real query I need 10 fields from $rs1 and only one from $rs2 (there are only 4 fields in the table referenced in $rs2).
Thanks in advance for any assistance with this.
Here is an example of what is going on (I am typing this on the fly):
Code:
$sql1 = "Select name, age, gender from tblPERSON";
$rs1 = $db->Query($sql1);
while($row1 = $db->FetchRow($rs1))
{
$list = '';
$sql2 = "Select book from tblBOOKS Where age_grp = $row1[age]";
$rs2 = $db->Query($sql2);
while($row2 = $db->FetchRow($rs2))
{
$list .= "$row2[book], ";
}
echo "$row1[name], a $row1[age] year old $row1[gender] would like these books: $list";
}
If I run the above, what I will get is the first field from $rs1 only. If I modified $sql2 to be "SELECT book, author from ..." then I would get the first 2 fields from $rs1. And of course, if I modify $sql2 to be "SELECT book, author, isbn FROM ..." I get the first 3 fields...
Obvious pattern, and probably a newbie issue...but I do not know what to do. In my real query I need 10 fields from $rs1 and only one from $rs2 (there are only 4 fields in the table referenced in $rs2).
Thanks in advance for any assistance with this.