Jump to content


Photo

Calculation to be done row each row


  • Please log in to reply
1 reply to this topic

#1 dalton6275

dalton6275
  • New Members
  • Pip
  • Newbie
  • 6 posts

Posted 10 April 2006 - 11:09 AM

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.

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

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



#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 10 April 2006 - 07:06 PM

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)
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users