DataTables not working
DataTables not working
index.html
[code]
id
date
location
1
05/01/2013
SF
2
05/01/2013
SF
3
05/01/2013
SF
4
05/01/2013
SF
5
05/01/2013
SF
window.onload = function(){
$.post('sql.php', function (output) {
$('#result').html(output).show();
}).fail(function () { console.log('fail')});
};
$(document).ready(function(){
$('#result_table').dataTable();
});
$(document).ready(function(){
$('#example').dataTable();
});
[/code]
sql.php
[code]
<?php
$connection = SQL_connection;
$row = some sql query;
writeTable($row);
function writeTable($row){ ?>
ID
Date
Location
Status
Summary
<?php
foreach ($row as $row) { ?>
<?= $row['id'] ?>
<?= $row['date'] ?>
<?= $row['location'] ?>
<?= $row['status'] ?>
<?= $row['summary'] ?>">
<?php } ?>
<?php }
[/code]
#result is an empty div where I want to show the result_table after running a mysql query (done in sql.php). however, result_table is not converted to a DataTable. the #example table is a table I created in my html to test if DataTable is working, and it is. can someone help me please?
[code]
id
date
location
1
05/01/2013
SF
2
05/01/2013
SF
3
05/01/2013
SF
4
05/01/2013
SF
5
05/01/2013
SF
window.onload = function(){
$.post('sql.php', function (output) {
$('#result').html(output).show();
}).fail(function () { console.log('fail')});
};
$(document).ready(function(){
$('#result_table').dataTable();
});
$(document).ready(function(){
$('#example').dataTable();
});
[/code]
sql.php
[code]
<?php
$connection = SQL_connection;
$row = some sql query;
writeTable($row);
function writeTable($row){ ?>
ID
Date
Location
Status
Summary
<?php
foreach ($row as $row) { ?>
<?= $row['id'] ?>
<?= $row['date'] ?>
<?= $row['location'] ?>
<?= $row['status'] ?>
<?= $row['summary'] ?>">
<?php } ?>
<?php }
[/code]
#result is an empty div where I want to show the result_table after running a mysql query (done in sql.php). however, result_table is not converted to a DataTable. the #example table is a table I created in my html to test if DataTable is working, and it is. can someone help me please?
This discussion has been closed.
Replies