Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:33:29+00:00 2026-06-13T14:33:29+00:00

First of all I am using JQGrid in my application. After changing my CSS

  • 0

First of all I am using JQGrid in my application. After changing my CSS to Bootstrap CSS.
I have to use DataTable. I want to reuse my controller pages which makes query to display the data in JQGrid.

Here is my controller page.

<?php

require_once("JsonHeader.php");
$at = $_SESSION['abc'];
$start_date = $_SESSION['start_date'];
$end_date = $_SESSION['end_date'];
if ($_SESSION['list'] == '-1') {
    $user_query = "";
} else {
    $user_list = $_SESSION['list'];
    $user_query = " AND a.user_id IN ($list)";
}
$start_date = $_SESSION['start_date'];
$end_date = $_SESSION['end_date'];

if ($_SESSION['list'] == '-1') {
    $user_query = "";
} else {
    $user_list = $_SESSION['list'];
    $user_query = " AND a.user_id IN ($list)";
}

$page = $_GET['page']; // get the requested page
$limit = $_GET['rows']; // get how many rows we want to have into the grid 
$sidx = $_GET['sidx']; // get index row - i.e. user click to sort
$sord = $_GET['sord']; // get the direction 
$qtype = '';  // Search column
$query = '';  // Search string
if (isset($_GET['searchField'])) {
    $qtype = mysql_real_escape_string($_GET['searchField']);
}
if (isset($_GET['searchString'])) {
    $query = mysql_real_escape_string($_GET['searchString']);
}
if (isset($_GET['searchOper'])) {
    switch ($_GET['searchOper']) {
        case 'eq':
            $oper = '=';
            $query = mysql_real_escape_string($_GET['searchString']);
            break;
        case 'ne':
            $oper = '!=';
            $query = mysql_real_escape_string($_GET['searchString']);
            break;
        case 'cn':
            $oper = 'like';
            $query = "%".mysql_real_escape_string($_GET['searchString'])."%";
            break;
    }
}
$searchSql1 = ($qtype != '' && $query != '') ? "and $qtype $oper '$query'" : '';

if (!$sidx)
    $sidx = 1; // connect to the database 
$result = mysql_query(sprintf("SELECT  ae.col1,ae.col2,ae.col3, ae.col4,ae.col5,ae.col6,ae.col7,a.col8,a.col9,r.col10,p.col11
                           FROM $tablename3 ae,$tableName a, $tablename1 p, $tablename2 r
                           WHERE ae.col1=$at  $searchSql1
                           AND a.col1 = $at
                           AND a.col5=r.col5
                           AND a.col6=p.col6
                            $user_query"));
$row = mysql_num_rows($result);
$count = $row;
if ($count > 0) {
    $total_pages = ceil($count / $limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages)
    $page = $total_pages; $start = $limit * $page - $limit; // do not put 
$limit * ($page - 1);
$SQL = sprintf("SELECT  ae.col1,ae.col2,ae.col3, ae.col4,ae.col5,ae.col6,ae.col7,a.col8,a.col9,r.col10,p.col11
                           FROM $tablename3 ae,$tableName a, $tablename1 p, $tablename2 r
                           WHERE ae.col1=$at  $searchSql1
                           AND a.col1 = $at
                           AND a.col5=r.col5
                           AND a.col6=p.col6
                            $query");

$result = mysql_query($SQL) or die("Couldn t execute query." . mysql_error());
$responce = new stdClass();
$responce->page = new stdClass();
$responce->total = new stdClass();
$responce->records = new stdClass();

$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$i = 0;
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {


    $responce->rows[$i]['id'] = $row['col1'];
    $responce->rows[$i]['cell'] = array($row['col1'], $row['col2'], $row['col3'], $row['col4'], $row['col5'], $row['col6'], $time, $row['col7']);
    $i++;
}
echo json_encode($responce);
?>

HOW can I change this for DataTable?.
Please provide me the best way…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:33:30+00:00Added an answer on June 13, 2026 at 2:33 pm

    Finally I found how to resue my controller page for DataTable. Simply change the post variables in the controller page.
    Like

    $_GET['page']; By $_REQUEST['sEcho']
    $_GET['rows']; By $_REQUEST['iDisplayStart'],$_REQUEST['iDisplayLength']
    $_GET['sord']; $_REQUEST['sSortDir_0']
    $_GET['searchString']: $_GET['sSearch']: 
    
    And some changes the json response like 
    $ans['iTotalRecords'] = $count;
    $ans['iTotalDisplayRecords'] = $count;
    $ans['aaData'] = $aadata;
    
    echo json_encode($ans);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

first of all I'm using MySql. I have to create a advance search field
First of all: I'm at Scala 2.8 I have a slight issue while using
I'm using opengl and trying to create a first person camera. All examples use
I have 3 cards. at first all cards move to the right, then after
I am using JQGrid now. First of all, I would like to create listing
This is the first time I'm using jqgrid. I have confused in how to
I have this ASP.Net Page with jqGrid, all what I want is to add
Background We have a WinForms application with Entity Framework 4.2 code-first / FluentAPI using
First of all, I want to describe my project architecture: My project uses jqGrid.
I have created my first application for android Hello android. With using Eclipse, ADT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.