Jump to content

Calculation to be done row each row


dalton6275

Recommended Posts

Hello Everyone,

I am currently programming a online reporting system and I am trying to minus a total outage percentage from 100 but im not doing something correctly. The code i have is below.

[code]
<?php
$colname_Recordset1 = "1";
if (isset($_GET['sla'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['sla'] : addslashes($_GET['sla']);
}
mysql_select_db($database_Dalton, $Dalton);
$query_Recordset1 = sprintf("SELECT * FROM incidents WHERE SLA = '%s'", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $Dalton) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?> #sets up the recordset in Dreamweaver

<?php do { ?>
  <tr>
    <td> <a href="fypincidentedit.php?recordID=<?php echo $row_Recordset1['ID_NO']; ?>"> <?php echo $row_Recordset1['ID_NO']; ?>  </a> </td>
    <td> <?php echo $row_Recordset1['severity']; ?>  </td>
    <td> <?php echo $row_Recordset1['title']; ?>  </td>
    <td> <?php echo $row_Recordset1['SLA']; ?>  </td>
    <td> <?php echo $row_Recordset1['AccentureResp']; ?>  </td> # creates table showing all the rows from the query.
  
  <? if ($row_Recordset1['AccentureResp'] = 'N') {
          $outagecalc = $row_Recordset1['UNIX_TIMESTAMP(outage_end)'] - $row_Recordset1['UNIX_TIMESTAMP(outage_start)'];
          $outagetime = $outagecalc / 60;
        $outageeffect = ($outagecalc / 42320) * $row_Recordset1['percentage'];
        $totouttime = $totouttime + $outageeffect;
        };
  ?> # calculations that i am trying to perform on each row in the table that has AccentureResp field set to 'N'.
  <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</tr></table>
[/code]

What i am trying to do is set the calculations to perform on each row that has AccentureResp = 'N', but i dont think that i have the correct code for performing the loop as it is telling me that $totoutime = 0 everytime which lead me to believe that the loop is not working correctly.

Anyone know where i am going wrong???

Link to comment
Share on other sites

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.