All Results Showing at top of page

All Results Showing at top of page

gwpaulgwpaul Posts: 7Questions: 0Answers: 0
edited March 2013 in General
I am using server_processing.php, it connects and returns data, however all rows are returned at the top the page, then the datatables display correctly underneath.

At the top of the page I get this:(I am showing 2 of 2190 results which display)

{"sEcho":0,"iTotalRecords":"2190","iTotalDisplayRecords":"2190","aaData":[["Jonathan","D.","Davis","U. S. Marine","34","2\/22\/2013","Kayenta","Arizona"],["Mark","H.","Schoonhoven","U. S. Army","38","1\/20\/2013","Plainwell","Michigan"]

The page can be viewed at https://www.egoodbyes.com/site/pagin.php

The js I have is

[code]
$(document).ready(function() {
$('#table_id').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "server_processing.php"
} );
} );
[/code]

The HTML table
[code]



First Name
MI
Last Name
Branch of Service
Age
Date of Death
Town
State

















[/code]

And the server_processing is

[code]


<?php
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Easy set variables
*/

/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array('fname', 'mi', 'lname','occup', 'age', 'dod', 'town','state');

/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "vic_id";

/* DB table to use */
$sTable = "victims";

/* Database connection information */
$gaSql['user'] = "xxx";
$gaSql['password'] = "xxxxx";
$gaSql['db'] = "xx_xxx";
$gaSql['server'] = "xxxxxx";

/* REMOVE THIS LINE (it just includes my SQL connection user/pass) */
//include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* If you just want to use the basic configuration for DataTables with PHP server-side, there is
* no need to edit below this line
*/

/*
* Local functions
*/
function fatal_error ( $sErrorMessage = '' )
{
header( $_SERVER['SERVER_PROTOCOL'] .' 500 Internal Server Error' );
die( $sErrorMessage );
}


/*
* MySQL connection
*/
if ( ! $gaSql['link'] = mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password'] ) )
{
fatal_error( 'Could not open connection to server' );
}

if ( ! mysql_select_db( $gaSql['db'], $gaSql['link'] ) )
{
fatal_error( 'Could not select database ' );
}


/*
* Paging
*/
$sLimit = "";
if ( isset( $_GET['iDisplayStart'] ) && $_GET['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".intval( $_GET['iDisplayStart'] ).", ".
intval( $_GET['iDisplayLength'] );
}


/*
* Ordering
*/
$sOrder = "";
if ( isset( $_GET['iSortCol_0'] ) )
{
$sOrder = "ORDER BY ";
for ( $i=0 ; $i $iFilteredTotal,
"aaData" => array()
);

while ( $aRow = mysql_fetch_array( $rResult ) )
{
$row = array();
for ( $i=0 ; $i
[/code]

Can anyone point me to the error of my ways?

Thank you

Gary

Replies

  • gwpaulgwpaul Posts: 7Questions: 0Answers: 0
    In case someone else has the same issue, I posted the question on Stackoverflow and the issue was I had put the server_processing.php as an include in the html file on line 1and it was not required.

    Gary
This discussion has been closed.