Jump to content

Recommended Posts

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>

 

 

Link to comment
https://forums.phpfreaks.com/topic/102598-showing-4-columns-in-rows/
Share on other sites

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.