I have a DataTable
filled with a query, the problem is that in the database I do not have as many zeros as it shows in DataTable
How can I remove them?
In addition to this how can I edit some characteristics of DataTable
. The results are shown as follows:
The query is simple, the code is below:
<?php
session_start();
if(isset($_SESSION['usuario'])){
require 'vistas/catalogo.view.php';
}else{
header('location:servicios.php');
}
//if ($_SERVER['REQUEST_METHOD'] == 'POST') {
try {
$servidor='(LOCAL)';
$base='dbsav300';
$usuario='XXX';
$password='XXXXX';
$conexion=new PDO ("sqlsrv:server=$servidor;Database=$base", "$usuario", "$password");
echo "Conexion establecida";
} catch (Exception $e) {
echo "Error en la conexion:" .$e->getMessage(). "\n";
exit;
}
$consulta=$conexion->prepare('SELECT art_Clave, art_Nombre, art_Total, art_Existencia FROM tArticulo');
$consulta->execute();
echo "<table id='table_id' class='display'>";
echo "<thead>";
echo "<tr>";
echo "<th>SKU</th>";
echo "<th>NOMBRE</th>";
echo "<th>PRECIO DE VENTA</th>";
echo "<th>EXISTENCIA</th>";
echo "</tr>";
echo "</thead>";
echo "<tbody>";
while ($row=$consulta->fetch()) {
//print_r($row);
echo "<tr>";
echo '<th>'.$row['art_Clave'].'</th>';
echo '<th>'.$row['art_Nombre'].'</th>';
echo '<th>'.$row['art_Total'].'</th>';
echo '<th>'.$row['art_Existencia'].'</th>';
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
?>
And the function I call it like this:
<script type="text/javascript">
$(document).ready( function () {
$('#table_id').DataTable();
} );
</script>
The funny thing that in another part of the page made the same query and is shown correctly: