Jump to content


This topic is now archived and is closed to further replies.


Calculation to be done row each row

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.

$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 { ?>
    <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)); ?>

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???

Share this post

Link to post
Share on other sites
UNIX_TIMESTAMP() is a MySql function for use within queries. You cannot use it in a php script (other than in the text of query)

Share this post

Link to post
Share on other sites


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.