Datatables only returning first letter

Datatables only returning first letter

drisatedrisate Posts: 2Questions: 1Answers: 0
edited October 2014 in Free community support

Hey guys i am trying to use datatables in a server side scenario. I am trying to show all the data into one cell. The JSON seems to be valide but for some reason, Datatables initiates it self but shows only the first letter of the data. for each rows...

Let say the data looks like: "Hello World"
For some reason it will only show H ... What happend to the reste of the string? I validated the JSON ... searched everywhere for an explanation but found nobody else having my problem. Any help would be greatly appreciated. Thanks in advance!

Javascript:

$(document).ready( function () {
    $('#listcontact2').dataTable( {
        "iDisplayLength": 25,
        "bLengthChange": false,
        "ordering": false,
        "stateSave": true,
        "sAjaxSource": "include/ajax.php?contact_list=1",
        "processing": true,
        "serverSide": true,
        "deferRender": true
    });
});

HTML:

<table id="listcontact2" class="display" cellspacing="0">
    <thead>
        <tr>
            <th style="height: 25px;">Data</th>
        </tr>
    </thead>
</table>

PHP:

<?php
$select = mysql_query("SELECT * FROM entreprises");
while($ent = mysql_fetch_array($select)){

    $data[aaData][] = "$ent[entreprise] $ent[eid] $ent[prenom] $ent[nom] $ent[autre_contact_1] $ent[courriel] $ent[tel1] $ent[tel2] $ent[adresse] $ent[ville] $ent[province] $ent[cp] $ent[pays] $ent[commentaire] $ent[commentaire2] $ent[site] $ent[rbq] $ent[facebook]";
    $count++;

}

$data[draw]="25";
$data[recordsTotal]="$count";
$data[recordsFiltered]="$count";

echo json_encode($data);
?>

Answers

  • drisatedrisate Posts: 2Questions: 1Answers: 0

    I got it ...

    i had to modify my PHP like this:

    $data[aaData][] = array("$ent[entreprise] $ent[eid] $ent[prenom] $ent[nom] $ent[autre_contact_1] $ent[courriel] $ent[tel1] $ent[tel2] $ent[adresse] $ent[ville] $ent[province] $ent[cp] $ent[pays] $ent[commentaire] $ent[commentaire2] $ent[site] $ent[rbq] $ent[facebook]");

This discussion has been closed.