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 8727601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:27:51+00:00 2026-06-13T08:27:51+00:00

Hello StackOverFlow nation . I’m trying to add information to jqGrid , which is

  • 0

Hello StackOverFlow nation . I’m trying to add information to jqGrid , which is retrieved from MySQL database. I’ve two files => index.html and data.php (both in the same directory)

index.html source =>

<script type="text/javascript">
$(function(){
    $("#jqGrid_tb").jqGrid({
        url: "data.php",
        datatype: "json",
        sortable: true,
        height: "auto",
        colNames: ["Name","Surname","Birth Year","Famous Film"],
        colModel: [
            {name: "name", index: "name", width: "150"},
            {name: "surname", index: "surname", width: "150"},
            {name: "b_year", index: "year", width: "150"},
            {name: "film", index: "film", width: "200"}
        ],
        rowNum: 5,
        rowList: [5,10,15],
        viewrecords: true,
        pager: $("#pager"),
        caption: "Famous Actors",
    }).navGrid("#pager");
});
</script>

<div id="grid">
    <table id="jqGrid_tb"></table>
    <div id="pager"></div>
</div>

data.php source =>

include ("JSON.php");

$json = new Services_JSON();

$con = new mysqli("host","user","pswd","db");

if (!$con->connect_errno){
    if ($r = $con->query("SELECT * FROM actors")){
        while ($row = $r->fetch_assoc()){
            $info[] = array(
                "name" => $row[name],
                "surname" => $row[surname],
                "b_year" => $row[b_year],
                "film" => $row[film],
            );
        }
        $r->free();
    }
}

echo $json->encode($info);

if (isset($con)){
    $con->close();
}

jqGrid is shown without any information in index.html file , also when opening data.php file information is successfully encoded into JSON format , whats wrong I can’t understand . Please help , thanks …

  • 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-13T08:27:53+00:00Added an answer on June 13, 2026 at 8:27 am

    Your response format is wrong. You can go to jqGrid Demos page where you will find a sample for PHP/MySQL after expanding Loading Data and then choosing JSON Data.

    The proper format of data should look like this:

    {
        "total": "1",
        "page": "1",
        "records": "2",
        "rows": [
            { "name": "Robert", "surname": "De Niro", "b_year": "1943", "film": "Once Upon A Time In America" },
            { "name": "Al", "surname": "Pacino", "b_year":"1971", "film": "Scent Of A Woman"}
        ]
    }
    

    Where:

    • total –> total count of pages
    • page –> current page number
    • records –> total count of records
    • rows –> the rows of data

    Also if you want rows to be objects, you need to disable repeatitems in jqGrid jsonReader options:

    $("#jqGrid_tb").jqGrid({
        ...
        jsonReader: { repeatitems: false }
    });
    

    It is also adviced for rows to have unique id for later reference.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello stackoverflow people! I've got a problem which I haven't been able to solve
Hello stackoverflow community ! I am trying to figure out how to architect my
Hello StackOverflow Users, I am new to android and trying to develop a game
Hello people from stackoverflow I have found more IE7 problems (tested in compatibility mode
Hello StackOverflow, I have an ASP.NET/C# webpage that calls functions from a managed .dll
Hello kind folks of StackOverflow. I am trying to make a sort of 'bot'
Hello, stackoverflow community! I am working on a rather large database-driven web application. The
Hello people from StackOverflow! I come to you with yet another question. :) As
Hello Stackoverflow users, I have a question regarding an JQ UI widget im trying
Possible Duplicate: Copy a linked list Hello stackoverflow! I am trying to learn more

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.