Trying to use Datatables- none of the functions are working (sorting pagination etc)

Trying to use Datatables- none of the functions are working (sorting pagination etc)

NazirNazir Posts: 7Questions: 0Answers: 0
edited January 2013 in General
Hi Guys,

I lvoe this script but Can't seem to get it to work when pulling data from a MySQL table.

this is the code im using in php:

[code]

function table() //used to display the data on the main pages

{
$databasereturn = $this->getData(1);
if(count($databasereturn)>0) //checks that some data comes back if so creates table, if not outputs message

{
$output.="";
$output.="";
$output.="";
$output.="Acronym";
$output.="FullTitle";
$output.="Abstract";
$output.="";
$output.="";


foreach($databasereturn as $query):
$output.="";
$output.="";
$output.="".$query['Acronym']."";
$output.="".$query['FullTitle']."";
$output.="".$query['Abstract']."";
$output.="";
$output.="";

endforeach;

$output.="";
[/code]

It shows all the data from the table howevcer its not sorting or paginating are my tags incorrect?

Thanks guys

Replies

  • NazirNazir Posts: 7Questions: 0Answers: 0
    ALso the CSS is only working on the very last row.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Please link to a test case.

    Allan
  • NazirNazir Posts: 7Questions: 0Answers: 0
    edited January 2013
    I'd love to post an example but can't sorry :(

    I can get this script to work if im creating a table in html however as I'm pulling the data from mysql table the sorting, pagination and css is not working.

    The options appear to limit the rows, however the rows are not limiting and when i click the header titles they are not sorting.

    Can I post an image of it instead? I cant post a direct link either as it is on an internal restricted network.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Use the debugger - that might give us a clue.
  • NazirNazir Posts: 7Questions: 0Answers: 0
    just tried it i got the following code: egakep
  • NazirNazir Posts: 7Questions: 0Answers: 0
    Just looking at the SQL table. The very first row entry which is A&E seems to be the last showing in the data table and this is the one row which shows css too.

    the Table summary seems to show the rows as 1 in debugger?
  • NazirNazir Posts: 7Questions: 0Answers: 0
    I've figured out what the issue is but I can't think of how to solve it! lol

    The datatable is only recognising row 1 however the whole table is loading above it.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You've got your code creating multiple TBODY elements. One for every row in fact. I'd suggest you probably don't want that... :-)

    Allan
  • NazirNazir Posts: 7Questions: 0Answers: 0
    ahhh man nice one lol :D

    Such a stupid error :smack:

    Its working perfectly now thanks :D
This discussion has been closed.