Sorting and filtering problem
Sorting and filtering problem
microsound
Posts: 6Questions: 0Answers: 0
Hello Everyone here,
I am trying to build this server side processing script based on some post I found from other users, but I cannot get the sort and filter function to work. Its been a week now, at the moment for simplicity I use just a simple table, but later I would use join function. If anyone could give me a helping hand why sorting and filtering not working, it would be great.
[code]<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * 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)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
session_start();
if(!session_is_registered(name)){
header("location:login.php");
}
define('INCLUDE_CHECK',true);
include 'config.inc.php';
include 'includes/member_common.php';
$aColumns = array("s.id AS id", "s.start_date AS start_date", "s.days AS days", "s.site AS site");
/*, "a.name site",
"b.name guest1", "c.name guest2", "d.name guest3", "e.name guest4"); */
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "s.id";
/* DB table to use */
$sTable = "schedules s";
// any JOIN operations that you need to do
$sJoins = "";
/*"LEFT JOIN texchanges a
on s.site = a.id
LEFT JOIN texchanges b
on s.guest1 = b.id
LEFT JOIN texchanges c
on s.guest2 = c.id
LEFT JOIN texchanges d
on s.guest3 = d.id
LEFT JOIN texchanges e
on s.guest4 = e.id";*/
// get or post
$_METHOD = $_POST;
/* * Paging * */
$sLimit = "";
if ( isset( $_METHOD['iDisplayStart'] ) && $_METHOD['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_METHOD['iDisplayStart'] ).", ".
mysql_real_escape_string( $_METHOD['iDisplayLength'] );
}
/* * Ordering */
if ( isset( $_METHOD['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]
I am trying to build this server side processing script based on some post I found from other users, but I cannot get the sort and filter function to work. Its been a week now, at the moment for simplicity I use just a simple table, but later I would use join function. If anyone could give me a helping hand why sorting and filtering not working, it would be great.
[code]<?php
/*
* Script: DataTables server-side script for PHP and MySQL
* Copyright: 2010 - Allan Jardine
* License: GPL v2 or BSD (3-point)
*/
/* * * * * * * * * * * 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)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
session_start();
if(!session_is_registered(name)){
header("location:login.php");
}
define('INCLUDE_CHECK',true);
include 'config.inc.php';
include 'includes/member_common.php';
$aColumns = array("s.id AS id", "s.start_date AS start_date", "s.days AS days", "s.site AS site");
/*, "a.name site",
"b.name guest1", "c.name guest2", "d.name guest3", "e.name guest4"); */
/* Indexed column (used for fast and accurate table cardinality) */
$sIndexColumn = "s.id";
/* DB table to use */
$sTable = "schedules s";
// any JOIN operations that you need to do
$sJoins = "";
/*"LEFT JOIN texchanges a
on s.site = a.id
LEFT JOIN texchanges b
on s.guest1 = b.id
LEFT JOIN texchanges c
on s.guest2 = c.id
LEFT JOIN texchanges d
on s.guest3 = d.id
LEFT JOIN texchanges e
on s.guest4 = e.id";*/
// get or post
$_METHOD = $_POST;
/* * Paging * */
$sLimit = "";
if ( isset( $_METHOD['iDisplayStart'] ) && $_METHOD['iDisplayLength'] != '-1' )
{
$sLimit = "LIMIT ".mysql_real_escape_string( $_METHOD['iDisplayStart'] ).", ".
mysql_real_escape_string( $_METHOD['iDisplayLength'] );
}
/* * Ordering */
if ( isset( $_METHOD['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]
This discussion has been closed.
Replies