// Connect to rel table to find relation between user and condition. dbConnect('leg'); $pquery="SELECT * FROM `rel_Conditions_Profile` WHERE `pid` = '1'"; $presult=mysql_query($pquery); $pnum=mysql_numrows($presult); mysql_close(); // For every condition related to the user $p = 0; while ($p < mysql_numrows($presult)){ $cid=mysql_result($presult,$p,"cid"); // Connect to conditions table and retreive the extra info. dbConnect('leg'); $xquery="SELECT * FROM `conditions` WHERE `id` = '$cid'"; $xresult=mysql_query($xquery); $xnum=mysql_numrows($xresult); mysql_close(); // Output this div for each condition matched to the user. $title=mysql_result($xresult,$p,"title"); $description=mysql_result($xresult,$p,"description"); echo "
"; $p++; } ?>