Tema: json_encode
Ver Mensaje Individual
  #3 (permalink)  
Antiguo 15/10/2019, 09:38
Parliament
 
Fecha de Ingreso: noviembre-2003
Mensajes: 499
Antigüedad: 20 años, 5 meses
Puntos: 7
Respuesta: json_encode

Digo que son los acentos y las eñes por que cuando a la tabla le escribo una palabra con acentos y con eñes, se para el programa.
Este es el index
Código PHP:
<!DOCTYPE html>
<
head>
    <
script src="vendor/jquery/jquery-3.2.1.min.js"></script>

    <link rel="stylesheet"  href="vendor/DataTables/jquery.datatables.min.css">    
    <script src="vendor/DataTables/jquery.dataTables.min.js" type="text/javascript"></script> 

    <link href="style.css" rel="stylesheet" type="text/css" />

    <title>Column Search in DataTables using Server-side Processing</title>
    <script>
        $(document).ready(function ()
        {
            $('#tbl-contact thead th').each(function () {
                var title = $(this).text();
                $(this).html(title+' <input type="text" class="col-search-input" placeholder="Search ' + title + '" />');
            });
            
            var table = $('#tbl-contact').DataTable({
                    "scrollX": true,
                    "pagingType": "numbers",
                "processing": true,
                "serverSide": true,
                "ajax": "server.php",
                order: [[2, 'asc']],
                columnDefs: [{
                    targets: "_all",
                    orderable: false
                 }]
            });

            table.columns().every(function () {
                var table = this;
                $('input', this.header()).on('keyup change', function () {
                    if (table.search() !== this.value) {
                           table.search(this.value).draw();
                    }
                });
            });
        });

    </script>
</head>

<body>
    <div class="datatable-container">
        <h2>Column Search in DataTables using Server-side Processing</h2>
        <table name="tbl-contact" id="tbl-contact" class="display" cellspacing="0" width="100%">   

            <thead>
                <tr>
                    
                    <th>Name</th>
                    <th>Last Name</th>
                    <th>Address</th>
                    <th>Phone</th>
                    <th>Date Of Birth</th>

                </tr>
            </thead>
            
        </table>
    </div>
</body>
</html> 
y este es el server
Código PHP:
<?php
 

$table 
'tbl_contact';
 

$primaryKey 'id';
 

$columns = array(
    array( 
'db' => 'first_name''dt' => ),
    array( 
'db' => 'last_name',  'dt' => ),
    array( 
'db' => 'address',   'dt' => ),
    array( 
'db' => 'phone''dt' => 3,),
    array( 
'db' => 'date_of_birth','dt' => 4,
        
'formatter' => function( $d$row ) {
            return 
date'd-m-Y'strtotime($d));
        }
    )
   
);
 

$sql_details = array(
    
'user' => 'root',
    
'pass' => '',
    
'db'   => 'htl',
    
'host' => 'localhost'
);
 
 

 
require( 
'vendor/DataTables/server-side/scripts/ssp.class.php' );
 
echo 
json_encode(
    
SSP::simple$_GET$sql_details$table$primaryKey$columns )
)