Retrieving MySQL data and displaying in DataTables

Retrieving MySQL data and displaying in DataTables

smcac11smcac11 Posts: 7Questions: 0Answers: 0
edited July 2013 in General
Hi,

I've been trying to figure this out for a while and looked at similar posts on this topic, but I'm still stuck. I'm also a total newbie, developing my first website. Anyhow, here is what I'm trying to do. I have an html file with the front-end datatables code (from http://datatables.net/blog/Getting_started_with_DataTables%3A_First_steps); that file is functioning fine when I load in a browser. I'm now trying to integrate the server-side php code (from http://datatables.net/examples/data_sources/server_side.html) so that I can load data from mysql into DataTables. I put the the server-side PHP code in a separate inc.php document.

I also have a php document which requires both the html document and the php document with the server side code. However, when I try to load this document on my local server I get this message:

Warning: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/...datatables.inc.php:1) in /Applications/XAMPP/...datatables.inc.php on line 41
MySQL Error: 1064

Nothing precedes the initial code on line 1 (obviously) in the php document, so I'm not sure how I get: 'headers already sent by...'. All that's on that line is the opening "<?php" tag. I also am requiring the php document before requiring the html document.

Can someone please help? Could someone also tell me if this initialisation code is correct?


$(document).ready(function() {
$('#tablename').dataTable( {
"sPaginationType": "full_numbers"
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "../examples_support/server_processing.php"
} );
} );


I have a feeling I may have bigger problems than just the "headers" error message I'm getting. Perhaps I'm not integrating the php and html appropriately code/documents appropriately. In any case, any help would be much appreciated.

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    > Can someone please help? Could someone also tell me if this initialisation code is correct?

    We'd need to see the PHP code - perhaps post it into pastebin for us. Although I should say that this forum is not a place for PHP help in general, but we should be able to help with this one.

    Allan
  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    You're missing a comma after "full_numbers".
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    That'd do it. Well spotted :-)
  • smcac11smcac11 Posts: 7Questions: 0Answers: 0
    Thanks tangerine! I did also answer my first question. I had a couple of spaces before the opening php tag. After removing them, I no longer get the 'headers already sent' error.
This discussion has been closed.