DataTables plugin doesn't work - php

I've found this awesome plugin that sorts and filters and shows pagination etc. and I've tried it on a test empty page and it works. But when I put the same code on my project it doesn't. What is going on? The only difference I can see is that my app has PHP/Mysql data, but this plugin is supposed to work fine with both. :/
Links
<!-- BOOTSTRAP-->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<!-- JQUERY -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<!-- DATATABLES-->
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.13/af-2.1.3/b-1.2.4/b-colvis-1.2.4/b-flash-1.2.4/b-html5-1.2.4/b-print-1.2.4/cr-1.3.2/fc-3.2.2/fh-3.1.2/kt-2.2.0/r-2.1.1/rr-1.2.0/sc-1.4.2/se-1.2.0/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/v/bs-3.3.7/jq-2.2.4/jszip-2.5.0/pdfmake-0.1.18/dt-1.10.13/af-2.1.3/b-1.2.4/b-colvis-1.2.4/b-flash-1.2.4/b-html5-1.2.4/b-print-1.2.4/cr-1.3.2/fc-3.2.2/fh-3.1.2/kt-2.2.0/r-2.1.1/rr-1.2.0/sc-1.4.2/se-1.2.0/datatables.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.datatables.net/1.10.13/css/jquery.dataTables.css">
<script type="text/javascript" charset="utf8" src="//cdn.datatables.net/1.10.13/js/jquery.dataTables.js"></script>
Table
<div class="row">
<?php
$prepIexec = $conn->prepare('SELECT id, nom, zona, tlf, email, gats, coordinador FROM TaulaCasesAcollida ORDER BY nom ASC');
$prepIexec->execute();
if($prepIexec->rowCount() > 0){ ?>
<div class="table-responsive">
<table id="taula_acollida" class='table taulaAco display' cellspacing="0" width="100%">
<thead>
<tr>
<th class="taulaAco_fila1 uppercase">Nom</th>
<th class="taulaAco_fila1 uppercase">Zona</th>
<th class="taulaAco_fila1 uppercase">Telèfon</th>
<th class="taulaAco_fila1 uppercase">Email</th>
<th class="taulaAco_fila1 uppercase">Gats</th>
<th class="taulaAco_fila1 uppercase">Coordinador</th>
</tr>
</thead>
<?php
while($row = $prepIexec->fetch(PDO::FETCH_ASSOC)){
extract($row);
?>
<tbody>
<tr>
<td class="taulaAco_fila2 capitalize"><?php echo $nom; ?></td>
<td class="taulaAco_fila2"><?php echo $zona; ?></td>
<td class="taulaAco_fila2"><?php echo $tlf; ?></td>
<td class="taulaAco_fila2"><?php echo $email; ?></td>
<td class="taulaAco_fila2 capitalize"><?php echo $gats; ?></td>
<td class="taulaAco_fila2 capitalize"><?php echo $coordinador; ?></td>
<td class="taulaAco_fila2 E">
<a title="editar" href="editar_casaAcollida.php?edit_id=<?php echo $row['id']; ?>" title="editar"><i class="material-icons iconoEditar">mode_edit</i></a>
<a class="X" title="eliminar" href="?eliminar_id=<?php echo $row['id']; ?>" onclick="return confirm('Estàs segur que vols el·liminar aquesta casa d'acollida?')"><i class="material-icons iconoEliminar">cancel</i></a>
</td>
</tr>
<?php
}
}
else{
?>
<div class="col-xs-12">
<div class="alert alert-warning">No hi ha cases d'acollida.</div>
</div>
<?php
}
?>
</tbody>
</table>
</div>
</div>
Script
<script>
$(document).ready(function() {
$('#taula_acollida').dataTable();
});
</script>

Put <tbody> outside the while loop
You have 6 columns in <thead> and 7 columns in <tbody>. This causes mData error.

Related

DataTables can't read more than one Data

I would like to ask why is the DataTable can't read more than 1 data in my Database? I would appreciate any help since I'm relatively new with the Data Table, thank you.
As you can see it's only showing 1 to 1 of 1 entries. But as seen in the table I have 5 retrieved data.
and when I am trying to search in the search bar this shows up.
Here's the code for the table.
<table class="table table-striped table-hover table-condense" id="tbl_research">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Resarch Title</th>
<th scope="col">Research Type</th>
<th scope="col">Research Author</th>
<th scope="col">Action</th>
</tr>
</thead>
<tbody>
<tr>
<?php
include 'includes/connection_operation.php';
$sql = "SELECT * FROM tbl_repository";
$query = mysqli_query($conn,$sql);
if($query)
{
while($row = mysqli_fetch_assoc($query))
{
?>
<th><?php echo $row['ID']; ?></th>
<td><?php echo $row['research_title']; ?></td>
<td><?php echo $row['research_type']; ?></td>
<td><?php echo $row['research_author']; ?></td>
<td>
<input type="submit" name="submit" id="submit" value="View" class="btn btn-info"
data-toggle="modal" data-target="#viewResearchModal<?php echo $row["ID"];?>">
</td>
</tr>
</tbody>
<?php
include './helper/modal_viewresearch.php';
}
}
?>
</table>
Here's my code for my plugins/cdn
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>CRR | View Research</title>
<!-- Bootstrap CSS CDN -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" integrity="sha384-9gVQ4dYFwwWSjIDZnLEWnxCjeSWFphJiwGPXr1jddIhOegiu1FwO5qRGvFXOdJZ4" crossorigin="anonymous">
<!-- Our Custom CSS -->
<link rel="stylesheet" href="css/style.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css">
<!-- Font Awesome JS -->
<script defer src="https://use.fontawesome.com/releases/v5.0.13/js/solid.js" integrity="sha384-tzzSw1/Vo+0N5UhStP3bvwWPq+uvzCMfrN1fEFe+xBmv1C/AtVX5K0uZtmcHitFZ" crossorigin="anonymous"></script>
<script defer src="https://use.fontawesome.com/releases/v5.0.13/js/fontawesome.js" integrity="sha384-6OIrr52G08NpOFSZdxxz1xdNSndlD4vdcf/q2myIUVO0VsqaGHJsB0RaBE01VTOY" crossorigin="anonymous"></script>
</head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
<!-- Bootstrap JS -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
<script src="https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#sidebarCollapse').on('click', function () {
$('#sidebar').toggleClass('active');
});
});
</script>
<script>
$(document).ready(function() {
$(function () {
$('[data-toggle="popover"]').popover()
});
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
});
</script>
<script>
$(document).ready(function() {
$('#tbl_research').DataTable( {
} );
} );
</script>
</body>
</html>
I had to re-read my whole code for 3 times and the reason it only shows 1 is that the tbody was inside the loop, so it only sees 1. I had to move it outside the while loop so the data should be in one tbody thank you.

Is it possible export data from table using jQuery's datatables.js plugin afrer using PHP filter button?

I have created a sales-form in which the date and place of sale of products are selected:
After clicking on the "Szukaj" button, which means "search" or "filter"
the data from the database is extracted using PHP and MSQL queries. After the results of sale are displayed
I want to use the jQuery DATATABLES plug-in to export the data to EXCEL, PDF, etc. The problem is that it does not work and it only copies and exports the first line
Why?here is the admin.php file in which the sale is displayed with a script at the bottom that runs datatable:
<?php
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
$connect = new PDO("mysql:host=localhost;dbname=bukowski2", "root", "");
function fill_unit_select_box2($connect)
{
$output = '';
$query = "SELECT * FROM users WHERE user_id!=7";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$output .= '<option value="'.$row["user"].'">'.$row["user"].'</option>';
}
return $output;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery-3.5.1.min.js" a></script>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<script src="js2.js" async></script>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-ui.js" defer></script>
<link rel="stylesheet" href="style2.css">
<link rel="stylesheet" href="jquery-ui.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<script src="buttons\datatables.min.js" defer></script>
<script src="buttons\dataTables.buttons.min.js" defer></script>
<script src="buttons\buttons.flash.min.js" defer></script>
<script src="buttons\jszip.min.js" defer></script>
<script src="buttons\pdfmake.min.js" defer></script>
<script src="buttons\buttons.print.min.js" defer></script>
<script src="buttons\buttons.html5.min.js" defer></script>
<script src="buttons\vfs_fonts.js" defer></script>
<script src="buttons\js.js" defer></script>
</head>
<body>
<?php
$_SESSION['sales_date']=date('Y-m-d');
echo '<p class="logged">Zalogowany: '.$_SESSION['user'].' | '.$_SESSION['sales_date'].' | [ Wyloguj się ]</p>';
?>
<div class="wrapper">
<div class="tabs">
<ul>
<li class="active">
<span class="text">TABELA</span>
</li>
<li>
<span class="text">DODAJ/USUŃ</span>
</li>
<li>
<span class="text">3</span>
</li>
<li>
<span class="text">4</span>
</li>
</ul>
</div>
<div class="content">
<div class="tab_wrap" style="display: block;">
<div class="title"></div>
<div class="tab_content">
<div class="container" style="width:100%;">
<h3 align="center">Wyszukiwanie danych sprzedaży</h3><br /> <br /> <br />
<div class="col-md-3" style="float:left;">
<input type="text" name="date" id="date" class="form-control" placeholder="Wybierz datę" />
</div>
<div class="col-md-3" style="float:left;">
<select required name="item_from" id="item_from" class="form-control item_from"><option value="">
<?php echo fill_unit_select_box2($connect); ?>
</option></select>
</div>
<div class="col-md-5" style="float:left;">
<input type="button" name="filter" id="filter" value="Szukaj" class="btn btn-info" />
</div>
<div style="clear:both"></div>
<br />
<div id="order_table">
<table class="table table-bordered" id="example">
<thead>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align:center">Rozmiar</th>
<th width="10%" style="text-align:center">Cena PLN</th>
<th width="10%" style="text-align:center">KARTA PLN</th>
<th width="10%" style="text-align:center">Inna waluta1</th>
<th width="10%" style="text-align:center">Inna waluta2</th>
<th width="10%" style="text-align:center">Od</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align:center">Rozmiar</th>
<th width="10%" style="text-align:center">Cena PLN</th>
<th width="10%" style="text-align:center">KARTA PLN</th>
<th width="10%" style="text-align:center">Inna waluta1</th>
<th width="10%" style="text-align:center">Inna waluta2</th>
<th width="10%" style="text-align:center">Od</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 2</p>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 3</p>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 4</p>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#date").datepicker();
});
$('#filter').click(function(){
var date = $('#date').val();
var item_from=$('#item_from').val();
if(date != '')
{
$.ajax({
url:"filter.php",
method:"POST",
data:{date:date,item_from:item_from},
success:function(data)
{
$('#order_table').html(data);
}
});
}
else
{
alert("Please Select Date");
}
});
});
</script>
and below is the filter.php file which uses PHP and a MySQL query to extract data from the database, which I want to export using the DATATABLE plug-in buttons:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery-3.5.1.min.js" a></script>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<script src="js2.js" async></script>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-ui.js" defer></script>
<link rel="stylesheet" href="style2.css">
<link rel="stylesheet" href="jquery-ui.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<script src="buttons\datatables.min.js" defer></script>
<script src="buttons\dataTables.buttons.min.js" defer></script>
<script src="buttons\buttons.flash.min.js" defer></script>
<script src="buttons\jszip.min.js" defer></script>
<script src="buttons\pdfmake.min.js" defer></script>
<script src="buttons\buttons.print.min.js" defer></script>
<script src="buttons\buttons.html5.min.js" defer></script>
<script src="buttons\vfs_fonts.js" defer></script>
<script src="buttons\js.js" defer></script>
</head>
<body>
<?php
//filter.php
if(isset($_POST["date"])) {
//ustanawiamy połącznie z bazą danych
$connect = mysqli_connect("localhost", "root", "", "bukowski2");
if($_POST["item_from"]==""){
$query = "SELECT item_name.item_name,sizes.sizes,sales_table.total_pln,sales_table.total_cart_payment,sales_table.total_oc1,currencies.currency,users.user FROM item_name,sales_table,sizes,currencies,users WHERE sizes.size_id=sales_table.size_id AND item_name.id=sales_table.item_name_color AND currencies.id=sales_table.total_oc2 AND users.user_id=sales_table.user_id AND sales_date='".$_POST["date"]."' ORDER BY sales_id";
}else{
$query0="SELECT user_id FROM users WHERE user='".$_POST["item_from"]."'";
$result = mysqli_query($connect, $query0);
while($row = mysqli_fetch_assoc($result))
{
$e= $row['user_id']."<br>";
}
$user_id = (int)$e;
$query = "SELECT item_name.item_name,sizes.sizes,sales_table.total_pln,sales_table.total_cart_payment,sales_table.total_oc1,currencies.currency,users.user FROM item_name,sales_table,sizes,currencies,users WHERE sizes.size_id=sales_table.size_id AND item_name.id=sales_table.item_name_color AND currencies.id=sales_table.total_oc2 AND users.user_id=sales_table.user_id AND sales_date='".$_POST["date"]."' AND sales_table.user_id=".$user_id." ORDER BY sales_id";
}
$output='';
$result = mysqli_query($connect, $query);
$output .= '
<table class="table table-bordered" id="example">
<thead>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align: center">Rozmiar</th>
<th width="10%" style="text-align: center">Cena PLN</th>
<th width="10%" style="text-align: center">KARTA PLN</th>
<th width="10%" style="text-align: center">Inna waluta1</th>
<th width="10%" style="text-align: center">Inna waluta2</th>
<th width="10%" style="text-align: center">Od</th>
</tr>
</thead>
';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<tbody>
<tr>
<td>'. $row["item_name"] .'</td>
<td style="text-align: center">'. $row["sizes"] .'</td>
<td style="text-align: center">'. $row["total_pln"] .'</td>
<td style="text-align: center">'. $row["total_cart_payment"] .'</td>
<td style="text-align: center">'. $row["total_oc1"] .'</td>
<td style="text-align: center">'. $row["currency"] .'</td>
<td style="text-align: center">'. $row["user"] .'</td>
</tr>
</tbody>
';
}
}
else
{
$output .= '
<tr>
<td colspan="5">Brak danych</td>
</tr>
';
}
$output .= '</table>';
echo $output;
//zamykamy połączenie z bazą danych
mysqli_close($connect);
}
?>
</body>
The js code to initialize the table has been included in the buttons\js.js script file. Here is the code:
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy',
'csv',
'excel',
'pdf',
'print'
]
} );
} );
ok i solved. It was enough to remove the tag from the loop that printed the results because the tag was inserted each time a row of data was inserted. Closed

Problem displaying html with bootstrap-table.js

I have created a dynamic list with a bootstrap filter, but there is a problem displaying all the links.
I do not know why the HTML code is displayed
Please help me please.
cordially.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js" type="text/javascript"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/editable/bootstrap-table-editable.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/export/bootstrap-table-export.js" type="text/javascript"></script>
<script src="https://rawgit.com/hhurz/tableExport.jquery.plugin/master/tableExport.js" type="text/javascript"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.9.1/extensions/filter-control/bootstrap-table-filter-control.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.10.0/bootstrap-table.min.css" />
<link rel="stylesheet" type="text/css" href="https://rawgit.com/vitalets/x-editable/master/dist/bootstrap3-editable/css/bootstrap-editable.css" />
<link rel="stylesheet" type="text/css" href="https://rawgit.com/vitalets/x-editable/master/dist/bootstrap3-editable/css/bootstrap-editable.css" />
<table id="table"
data-toggle="table"
data-search="true"
data-filter-control="true"
data-show-export="true"
data-click-to-select="true"
data-toolbar="#toolbar">
<thead>
<tr>
<th data-field="state" data-checkbox="true"></th>
<th data-field="article" data-filter-control="input" data-sortable="true">Article</th>
<th data-field="composant" data-filter-control="select" data-sortable="true">Composant</th>
<th data-field="fournisseur" data-filter-control="input" data-sortable="true">Fournisseur</th>
</tr>
</thead>
<tbody>
<? while($row = $req->fetch(PDO::FETCH_ASSOC)){ ?>
<tr>
<td class="bs-checkbox "><input data-index="0" name="btSelectItem" type="checkbox"></td>
<td><?php echo $row['code_article'] ?></td>
<td><?php echo $row['comp'] ?></td>
<td><?php echo $row['fournisseur'] ?></td>
</tr>
<? } ?>
</tbody>
</table>
Add data-escape="false" to your table tag - then the "plain" HTML will be rendered
<table id="table"
...
data-escape="false"
>
see https://bootstrap-table.com/docs/api/table-options/#escape
Thank you very much
with attribute data-escape="false" it works perfectly.

Unable to stream pdf: headers already sent codeigniter

i had this error when i want to export my file to pdf
Unable to stream pdf: headers already sent
this is my function export_to_pdf inside the controller
function export_to_pdf() {
$this->load->helper('warsito_pdf_helper');
$this->load->model('gedung/gedung_model');
$data['row'] = $this->gedung_model->laporan_perawatan_keseluruhan();
$object = $this->load->view('manage/pdf_report_all', $data);
$filename = 'Report.pdf';
generate_pdf($object, $filename, true);
}
and i have helper with name warsito_pdf_helper like this
function generate_pdf($object, $filename, $direct_download = true) {
require_once 'dompdf/dompdf_config.inc.php';
$dompdf = new DOMPDF();
$dompdf->load_html($object);
$dompdf->render();
if($direct_download == true) {
$dompdf->stream($filename);
} else {
return $dompdf->output();
}
}
and finally the view for the pdf
pdf_report_all.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicons-->
<link rel="apple-touch-icon-precomposed" href="<?php echo base_url();?>assets/home/assets/img/favicon/apple-touch-icon-152x152.png">
<meta name="msapplication-TileColor" content="#FFFFFF">
<meta name="msapplication-TileImage" content="<?php echo base_url();?>assets/home/assets/img/favicon/mstile-144x144.png">
<link rel="icon" href="<?php echo base_url();?>assets/home/assets/img/favicon/favicon-32x32.png" sizes="32x32">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Materialize core CSS -->
<link href="<?php echo base_url();?>assets/home/materialize/css/materialize.css" rel="stylesheet" type="text/css">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
<link href="<?php echo base_url();?>assets/home/template.css" rel="stylesheet" type="text/css">
</head>
<body>
<center><b><h5>Laporan Pembayaran Keseluruhan</h5></b></center>
<!--
<div class="container">
<div class="row">
<div class="col s12 m12"> -->
<table class="bordered" align="center">
<tr>
<th>No</th>
<th>No Ref</th>
<th>Jenis Perawatan</th>
<th>Tanggal Pembayaran Tagihan</th>
<th>Jumlah Pembayaran</th>
</tr>
<?php foreach($row as $row): $no = 1; $total_pembayaran = 0;?>
<tr>
<td><?php echo $no++?></td>
<td><?php echo $row['NO_ID']?></td>
<td><?php echo $row['NAMA_PERAWATAN']?></td>
<td><?php echo $row['TANGGAL_PEMBAYARAN']?></td>
<td><?php echo "Rp. ".number_format($row['BIAYA'])?></td>
</tr>
<?php $total_pembayaran = $row['BIAYA'] + $total_pembayaran?>
<?php endforeach;?>
</table>
<table style="display: inline-block;">
<tr>
<td><b>Total Pembayaran Keseluruhan: </b></td>
<td><b><?php echo "Rp. ".number_format($total_pembayaran)?></b></td>
</tr>
</table>
<!--
</div>
</div>
</div> -->
<script src="<?php echo base_url();?>assets/home/assets/js/jquery.min.js"></script>
<script src="<?php echo base_url();?>assets/home/materialize/js/materialize.js"></script>
<script src="<?php echo base_url();?>assets/home/index.js"></script>
</body>
</html>
i have googling my problem before, mostly says this error occurs because i have an extra lines in my file i already try the solution from this link DOMPDF: Unable to stream pdf: headers already sent
and add the following code after the stream();
$f;
$l;
if(headers_sent($f,$l))
{
echo $f,'<br/>',$l,'<br/>';
die('now detect line');
}
but the error still happens, so anyone can tell me whats wrong with my method or my code, thanks
In your controller change $object = $this->load->view('manage/pdf_report_all', $data);
to $object = $this->load->view('manage/pdf_report_all', $data, TRUE);
And also change your view to
`
<center><b><h5>Laporan Pembayaran Keseluruhan</h5></b></center>
<table class="bordered" align="center">
<tr>
<th>No</th>
<th>No Ref</th>
<th>Jenis Perawatan</th>
<th>Tanggal Pembayaran Tagihan</th>
<th>Jumlah Pembayaran</th>
</tr>
<?php foreach($row as $row): $no = 1; $total_pembayaran = 0;?>
<tr>
<td><?php echo $no++?></td>
<td><?php echo $row['NO_ID']?></td>
<td><?php echo $row['NAMA_PERAWATAN']?></td>
<td><?php echo $row['TANGGAL_PEMBAYARAN']?></td>
<td><?php echo "Rp. ".number_format($row['BIAYA'])?></td>
</tr>
<?php $total_pembayaran = $row['BIAYA'] + $total_pembayaran?>
<?php endforeach;?>
</table>
<table style="display: inline-block;">
<tr>
<td><b>Total Pembayaran Keseluruhan: </b></td>
<td><b><?php echo "Rp. ".number_format($total_pembayaran)?></b></td>
</tr>
</table>

jQuery DataTable appears without pagination control

I'm trying to insert Bootstrap pagination to my dynamic table content which I extract from my database as below, but nothing works:
<?php
$sn = $_POST["SN"];
$Reference = $_POST["Reference"];
$Libelle = $_POST["Libelle"];
$NOMENCLATURE = $_POST["NOMENCLATURE"];
$matricule = $_POST["matricule"];
include "./Connections/localhost.php";
$sqlTous = "
select mat.SN, mat.NOMENCLATURE, mat.ID_materiel, mat.Reference, mat.Date_affectation, mat.libelle, mat.Date_Acquisition, mat.Fournisseur,mat.commentaire, mat.Contrat from materiel mat
left join user usr on usr.ID_User = mat.ID_User ";
?>
<div>
<form method="post" action="./consultation.php" id="formClient">
<h4 class="widgettitle" width="10%" >Résultat</h4>
<br/>
<table class="table table-striped" id="example" class="display">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<?php
$reponse3 = mysql_query($sqlTous);
while ($rowMat1 = mysql_fetch_array($reponse3)) { ?>
<tbody class="table table-striped" id="example" class="display">
<tr>
<td><?php echo $rowMat1['SN']; ?></td>
<td><?php echo $rowMat1['NOMENCLATURE']; ?></td>
<td><?php echo $rowMat1['Reference']; ?></td>
<td><?php echo $rowMat1['libelle']; ?> </td>
<td><?php echo $rowMat1['Date_Acquisition']; ?></td>
<td><?php echo $rowMat1['Date_affectation']; ?></td>
</tr>
</tbody>
<?php } ?>
</table>
</form>
<script>
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
In addition, i have included the following js and css files:
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Recherche matériel</title>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.10/css/dataTables.bootstrap.min.css" type="text/css" />
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.10/js/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/jquery-migrate-1.1.1.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.9.2.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
There are some problems with your code:
tbody element shouldn't have id and class attributes and should be outside of the while loop.
You're including jquery-1.9.1.min.js twice.
<tbody>
<?php
$reponse3 = mysql_query($sqlTous);
while ($rowMat1 = mysql_fetch_array($reponse3)) { ?>
<tr>
<td><?php echo $rowMat1['SN']; ?></td>
<td><?php echo $rowMat1['NOMENCLATURE']; ?></td>
<td><?php echo $rowMat1['Reference']; ?></td>
<td><?php echo $rowMat1['libelle']; ?> </td>
<td><?php echo $rowMat1['Date_Acquisition']; ?></td>
<td><?php echo $rowMat1['Date_affectation']; ?></td>
</tr>
<?php } ?>
</tbody>

Categories