Crazy Horse Posted April 23, 2008 Share Posted April 23, 2008 Hi - and thanks in advance for any help!! I have a table which has the following row.. (8 columns).. this includes the output from 5 statements Currently I have while loops for each statement within individual <td></td> which successfully shows the data for each statement (each statement shows 20 rows - correct) but within the table cell and with no realtion to other columns. However ideally I need one while loop - the common factor in each statement is the first column "affreportname" So something like repeat this row for each statement where "affreportname" matches on that row I then need to create some calculations on this repeated row like column3/column4 but thats fine as long as I can get the columns related per row Hope this makes sense? And thanks again <tr> <td width="200" valign="top" bgcolor="#99CCCC"> <?php do { ?> <?php echo $row_rs_affinities['affreportname']; ?><br /> ------------------------------<br /> <?php } while ($row_rs_affinities = mysql_fetch_assoc($rs_affinities)); ?> </td> <td width="40" align="center" valign="top" bgcolor="#CCCCCC"><?php do { ?> <?php echo $row_rs_capture['COUNT(u.TeamCode)']; ?><br /> -----<br /> <?php } while ($row_rs_capture = mysql_fetch_assoc($rs_capture)); ?></td> <td width="40" align="center" valign="top">%</td> <td width="40" align="center" valign="top"><?php do { ?> <?php echo $row_rs_ulr['COUNT(u.TeamCode)']; ?><br /> -----<br /> <?php } while ($row_rs_ulr = mysql_fetch_assoc($rs_ulr)); ?></td> <td width="40" align="center" valign="top" bgcolor="#CCCCCC">%</td> <td width="40" align="center" valign="top" bgcolor="#CCCCCC"><?php do { ?> <?php echo $row_rs_pi['COUNT(u.TeamCode)']; ?><br /> -----<br /> <?php } while ($row_rs_pi = mysql_fetch_assoc($rs_pi)); ?></td> <td width="40" align="center" valign="top">%</td> <td width="40" align="center" valign="top"><?php do { ?> <?php echo $row_rs_hire['COUNT(u.TeamCode)']; ?><br /> -----<br /> <?php } while ($row_rs_hire = mysql_fetch_assoc($rs_hire)); ?></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/102598-showing-4-columns-in-rows/ Share on other sites More sharing options...
sasa Posted April 24, 2008 Share Posted April 24, 2008 can you post your SQL statement Quote Link to comment https://forums.phpfreaks.com/topic/102598-showing-4-columns-in-rows/#findComment-525742 Share on other sites More sharing options...
Crazy Horse Posted April 24, 2008 Author Share Posted April 24, 2008 Thanks for your help! It uses several sql statements on the same row, for example.. $query_rs_affinities = "SELECT miaffinityreports.affreportname FROM miaffinityreports WHERE affreportstatus = 'LIVE' ORDER BY miaffinityreports.affreportname "; $rs_affinities = mysql_query($query_rs_affinities, $conn_wiki) or die(mysql_error()); $row_rs_affinities = mysql_fetch_assoc($rs_affinities); $totalRows_rs_affinities = mysql_num_rows($rs_affinities); and.. SELECT r.affreportname, COUNT(d.extcaseno) FROM miaffinityreports r LEFT JOIN (miaffinities a INNER JOIN mipartnerdata d ON d.affinitycode = a.affcode AND d.fileopened ='$midate' AND d.passenger='N' AND d.nrcase = 'N' AND d.status = 'LIVE') ON r.affreportcode = a.affreportcode WHERE r.affreportstatus = 'LIVE' GROUP BY r.affreportname ORDER BY r.affreportname ASC and.. SELECT r.affreportname, COUNT(d.extcaseno) FROM miaffinityreports r LEFT JOIN (miaffinities a INNER JOIN mipartnerdata d ON d.affinitycode = a.affcode AND d.fileopened ='$midate' AND d.passenger='N' AND d.nrcase = 'N' AND d.faultornot = 'N' AND d.status = 'LIVE') ON r.affreportcode = a.affreportcode WHERE r.affreportstatus = 'LIVE' GROUP BY r.affreportname ORDER BY r.affreportname ASC etc Quote Link to comment https://forums.phpfreaks.com/topic/102598-showing-4-columns-in-rows/#findComment-525858 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.