calculated columns
calculated columns
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'> </td>";
echo "<td align='right'> </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
Answers
There are a few issues on your page.
The buttons aren't showing because you are loading datatables.js multiple times on lines 12, 17 and 40. Remove the lines 12 and 40 to load Datatables from the the concatenated JS on line 17. This should display allow the buttons to display.
You are getting this error in the browser's console:
ablea7.php:235:31
is pointing to thesummary
table. The table doesn't meet Datatables requirements for the HTML table. See the HTML docs for details. First there isn't athead
. Second issue is the table has 5 columns but you have one row with only 4. Datatables requires each row to have the same number of columns as the header row. Here is your HTML table:Kevin
Thanks, yes I added the labor force participation rate column recently.
Appreciate the advice.
I have removed lines 17 and 40.
the datatable I'm having a problem with is example.
for some reason, the excel button will not show up.
Thanks,
Virgil
I don't see those updates in your test case. I cleared my browser's cash but still see the same web page source. Please update the test case to show the issues you are currently having.
Kevin