Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82220

calculated columns

$
0
0

https://version8.guestworkervisas.com/tablea7.php

My table has the following columns.
Month varchar(255) DEFAULT NULL,
Year varchar(255) DEFAULT NULL,
Foreign Born Employed varchar(255) DEFAULT NULL,
Foreign Born Unemployed varchar(255) DEFAULT NULL,
Native Born Employed varchar(255) DEFAULT NULL,
Native Born Unemployed varchar(255) DEFAULT NULL,
id int(11) NOT NULL AUTO_INCREMENT,

From these, it calculates the rest of the columns.

while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
echo "<tr>";
$myr = $row['Month'] . ' ' . $row['Year'];
echo "<td>" . $myr . "</td>";
echo "<td align='right'>" . number_format($row['Foreign Born Employed']) . "</td>";
echo "<td align='right'>" . number_format($row['Foreign Born Unemployed']) . "</td>";
echo "<td align='right'>" . number_format($row['Foreign Born Unemployed'] + $row['Foreign Born Employed']) . "</td>";

      $currfb = $row['Foreign Born Unemployed'] + $row['Foreign Born Employed'];

      echo "<td align='right'>" . number_format($row['Native Born Employed']) . "</td>";
      echo "<td align='right'>" . number_format($row['Native Born Unemployed']) . "</td>";
      echo "<td align='right'>" . number_format($row['Native Born Unemployed'] + $row['Native Born Employed']) . "</td>";

      $currnb = $row['Native Born Unemployed'] + $row['Native Born Employed'];

      echo "<td align='right'>" . number_format($row['Foreign Born Employed'] + $row['Foreign Born Unemployed'] + $row['Native Born Employed'] + $row['Native Born Unemployed']) . "</td>";
      $twf = $row['Foreign Born Employed'] + $row['Foreign Born Unemployed'] + $row['Native Born Employed'] + $row['Native Born Unemployed'];
      echo "<td align='right'>" . round(($row['Foreign Born Employed'] + $row['Foreign Born Unemployed']) / $twf,3) . "</td>";
      echo "<td align='right'>" . round(($row['Native Born Employed'] + $row['Native Born Unemployed']) / $twf,3) . "</td>";

//foreign born gain
if (($currfb - $fboldest) > ($currnb - $nboldest)) {
echo "<td align='right' style='background-color:red; color:white'>" . $currfb - $fboldest . "</td>";
} else {
echo "<td align='right'>" . $currfb - $fboldest . "</td>";
}

//native born gain
if (($currnb - $nboldest) > ($currfb - $fboldest)) {
echo "<td align='right' style='background-color:green; color:white'>" . $currnb - $nboldest . "</td>";
} else {
echo "<td align='right'>" . $currnb - $nboldest . "</td>";
}
//echo "<td align='right'>" . $currnb - $nboldest . "</td>";
$wftotal = ($currfb - $fboldest) + ($currnb - $nboldest);
//combined gain
echo "<td align='right'>" . ($currfb - $fboldest) + ($currnb - $nboldest) . "</td>";

      //echo $myr;
      //echo "<td align='right' style='background-color:green'>" . round((($currnb - $nboldest) / $wftotal),3) . "</td>";
      if ($myr <> 'Jan 2007') {
        if ((($currfb - $fboldest) / $wftotal) > (($currnb - $nboldest) / $wftotal)) {
          echo "<td align='right' style='background-color:red; color:white'>" . round((($currfb - $fboldest) / $wftotal),3) . "</td>";
        } else {
          echo "<td align='right'>" . round((($currfb - $fboldest) / $wftotal),3) . "</td>";
        }
        if ((($currnb - $nboldest) / $wftotal) > (($currfb - $fboldest) / $wftotal)) {
          echo "<td align='right' style='background-color:green; color:white'>" . round((($currnb - $nboldest) / $wftotal),3) . "</td>";
        } else {
          echo "<td align='right'>" . round((($currnb - $nboldest) / $wftotal),3) . "</td>";
        }
      } else {

        echo "<td align='right'>&nbsp;</td>";
        echo "<td align='right'>&nbsp;</td>";


      }

I simply want to export this to excel so that people can download the data.
Works fine on all my other tables.
Just not this one with the calculated columns.

Thanks,

Virgil


Viewing all articles
Browse latest Browse all 82220

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>