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

  • SEARCH
  • Home
  • 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 6091559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:20:31+00:00 2026-05-23T12:20:31+00:00

This is the PHP code given <?php $aColumns = array( ‘engine’, ‘browser’, ‘platform’, ‘version’,

  • 0

This is the PHP code given

   <?php

    $aColumns = array( 'engine', 'browser', 'platform', 'version', 'grade' );

    $sTable = "ajax";
    $gaSql['user']       = "";
    $gaSql['password']   = "";
    $gaSql['db']         = "";
    $gaSql['server']     = "localhost";

    include( $_SERVER['DOCUMENT_ROOT']."/datatables/mysql.php" );   
    $gaSql['link'] =  mysql_pconnect( $gaSql['server'], $gaSql['user'], $gaSql['password']  ) or
        die( 'Could not open connection to server' );

    mysql_select_db( $gaSql['db'], $gaSql['link'] ) or 
        die( 'Could not select database '. $gaSql['db'] );

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

    $sOrder = "";
    if ( isset( $_GET['iSortCol_0'] ) )
    {
        $sOrder = "ORDER BY  ";
        for ( $i=0 ; $i<intval( $_GET['iSortingCols'] ) ; $i++ )
        {
            if ( $_GET[ 'bSortable_'.intval($_GET['iSortCol_'.$i]) ] == "true" )
            {
                $sOrder .= $aColumns[ intval( $_GET['iSortCol_'.$i] ) ]."
                    ".mysql_real_escape_string( $_GET['sSortDir_'.$i] ) .", ";
            }
        }

        $sOrder = substr_replace( $sOrder, "", -2 );
        if ( $sOrder == "ORDER BY" )
        {
            $sOrder = "";
        }
    }

    $sWhere = "";
    if ( isset($_GET['sSearch']) && $_GET['sSearch'] != "" )
    {
        $sWhere = "WHERE (";
        for ( $i=0 ; $i<count($aColumns) ; $i++ )
        {
            $sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string( $_GET['sSearch'] )."%' OR ";
        }
        $sWhere = substr_replace( $sWhere, "", -3 );
        $sWhere .= ')';
    }

    /* Individual column filtering */
    for ( $i=0 ; $i<count($aColumns) ; $i++ )
    {
        if ( isset($_GET['bSearchable_'.$i]) && $_GET['bSearchable_'.$i] == "true" && $_GET['sSearch_'.$i] != '' )
        {
            if ( $sWhere == "" )
            {
                $sWhere = "WHERE ";
            }
            else
            {
                $sWhere .= " AND ";
            }
            $sWhere .= $aColumns[$i]." LIKE '%".mysql_real_escape_string($_GET['sSearch_'.$i])."%' ";
        }
    }
    $sQuery = "
        SELECT SQL_CALC_FOUND_ROWS id, ".str_replace(" , ", " ", implode(", ", $aColumns))."
        FROM   $sTable
        $sWhere
        $sOrder
        $sLimit
    ";
    $rResult = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());

    $sQuery = "
        SELECT FOUND_ROWS()
    ";
    $rResultFilterTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
    $aResultFilterTotal = mysql_fetch_array($rResultFilterTotal);
    $iFilteredTotal = $aResultFilterTotal[0];

    /* Total data set length */
    $sQuery = "
        SELECT COUNT(".$sIndexColumn.")
        FROM   $sTable
    ";
    $rResultTotal = mysql_query( $sQuery, $gaSql['link'] ) or die(mysql_error());
    $aResultTotal = mysql_fetch_array($rResultTotal);
    $iTotal = $aResultTotal[0];

    $output = array(
        "sEcho" => intval($_GET['sEcho']),
        "iTotalRecords" => $iTotal,
        "iTotalDisplayRecords" => $iFilteredTotal,
        "aaData" => array()
    );

    while ( $aRow = mysql_fetch_array( $rResult ) )
    {
        $row = array();

        // Add the row ID and class to the object
        $row['DT_RowId'] = 'row_'.$aRow['id'];
        $row['DT_RowClass'] = 'grade'.$aRow['grade'];

        for ( $i=0 ; $i<count($aColumns) ; $i++ )
        {
            if ( $aColumns[$i] == "version" )
            {
                $row[] = ($aRow[ $aColumns[$i] ]=="0") ? '-' : $aRow[ $aColumns[$i] ];
            }
            else if ( $aColumns[$i] != ' ' )
            {
                $row[] = $aRow[ $aColumns[$i] ];
            }
        }
        $output['aaData'][] = $row;
    }

    echo json_encode( $output );
?>

I need to develop a program in java as like PHP code (I am unable to understand PHP code),
This is my java code(Partial).

public class DTSerializedObject implements java.io.Serializable
    {
        public int iTotalRecords;
        public int iTotalDisplayRecords;
        public ArrayList<Object> aaData;
    }

inside a function

    ArrayList<Object> jsonarray = new ArrayList<Object>();
    DTSerializedObject dts = new DTSerializedObject();
dts.iTotalRecords = dts.iTotalDisplayRecords = 30;
                String category=null;
                while(rs.next())
                {
                    category="Normal";
                    ArrayList<Object> ja = new ArrayList<Object>();
                    int topicno=rs.getInt("topicno");
                    ja.add(topicno);
                    ja.add(rs.getString("filename"));
                    ja.add(rs.getString("letterno"));
                    ja.add(rs.getString("date"));
                    if((rs.getString("category")).equals("2"))
                        category="Urgent";
                    ja.add("<center>"+category+"</center>");
                    ja.add(rs.getString("office"));
                    ja.add(rs.getString("subject")+"....");
                    ja.add("<center><a class='anc' href=\"/Spandana2/specifiedTopicDetailsAndReplies.do?topicno="+topicno+"&purpose=view&jsessionid="+java.util.UUID.randomUUID().toString().replace("-","").toUpperCase()+"\">View</a></center>");
                    jsonarray.add(ja);
                }
                dts.aaData = jsonarray;

How to add DT_RowId,DT_RowClass option to my java code.
What is the expected JSON output format for the above PHP code?

Thanks in advance

  • 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-05-23T12:20:31+00:00Added an answer on May 23, 2026 at 12:20 pm

    crate an object as like this

    class Bean{
          public String col1;
          public String col2;
          public String DT_RowClass;
    }
    

    while getting the data from db created an object(Bean) and assigned the values to that object properties for each and every row.

    ArrayList al = new ArrayList();    
    while(rs.next){
             Bean b = new Bean();
             b.col1(rs.getString(1));
             b.col2(rs.getString(2));
             if(rs.getString(3))
                  b.DT_RowClass = "class1";
             else
                  b.DT_RowClass = "class2";
             al.add(b);
        }
    

    created a class which represents the json format required to display the data in webpage.
    create object (obj) of that class and assigned the appropriate values to iTotalRecords & iTotalDisplayRecords & aaData = al;

    public class DTSerializedObject implements java.io.Serializable
        {
            public int iTotalRecords;
            public int iTotalDisplayRecords;
            public ArrayList<Object> aaData;
        }
    

    Finally serialize that object using flexjson.

     String result = new flexjson.JSONSerializer().exclude("class").serialize(obj);
        response.setContentType("application/json");
        response.setHeader("Cache-Control", "no-store");
        response.getWriter().print(result);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this PHP code: if (isset($_GET['c'])) { $pages = array(home, upload, signup);
I have this php code $jsonArray = array(); $sql = SELECT ID,CLIENT FROM PLD_SERVERS;
Given the php code: $xml = <<<EOF <articles> <article> This is a link <link>Title</link>
Given this PHP code: <a onclick=javascript:window.location.href='<?php echo $url;?>' What if there is a '
Given this PHP code: // total is 71.24 (float) $value = $total * 100;
This PHP code... 207 if (getenv(HTTP_X_FORWARDED_FOR)) { 208 $ip = getenv('HTTP_X_FORWARD_FOR'); 209 $host =
Say i have this PHP code: $FooBar = a string; i then need a
I have this php code, with which I am trying to generate a popup
I have this PHP code echo '<a href=# onclick=updateByQuery(\'Layer3\', ' . json_encode($query) . ');>Link
I am using this php code: exec(unrar e file.rar,$ret,$code); and getting an error code

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.