|
Posted by frothpoker on 09/01/06 13:27
// your query
$sql_query="SELECT DISTINCT casts.yearID, members.memberName"
. " FROM members INNER JOIN casts ON members.memberID =
casts.memberID"
. " WHERE (((casts.yearID) In (SELECT DISTINCT yearID FROM
casts WHERE memberID='$id')) AND ((casts.memberID)<>'$id'));";
$CurrentYear = 0;
while($result=mysql_query($sql_query); )
{
if ($CurrentYear == $result[1])
{
$string = $string .
"</TABLE><P><TABLE><TR><TD>$result[1]</TD></TR>";
$CurrentYear = $result[1]; // sets $CurrentYear to the same as
this record
} //end if statement
$string = $string . "<TR><TD>$result[2]</TD></TR>";
} // end while statement
print $string
-- code ends --
Obviously you will need to output table headers before the first record
and put some checking in so that you don't close the table if this is
the first record in the loop, but if i did it all for you....
Please note that I have not checked this for spelling or syntax (i am
notorious for leaving semi-colons off...)
Obiron
tzuriel wrote:
> Thanks for the suggestion. Would you be able to offer some code for
> consideration? I tried something like this at one point but couldn't
> get it to work.
>
> Thanks,
>
> Tzuriel
> frothpoker wrote:
> > two queries would be easier but obviously has a bigger overhead.
> >
> > You could do the following:
> >
> > Set $CurrentYear as the yearID from the first row
> >
> > on each time through the loop, check YearID against $CurrentYear and if
> > it is not the same then end the table and start a new one before
> > setting $CurrentYear to the yearID of the current row.
> >
> >
> >
Navigation:
[Reply to this message]
|