fail in loading data , please guide

114 views
Skip to first unread message

Kirshan

unread,
May 18, 2012, 7:01:34 AM5/18/12
to Flexigrid for jQuery
hi
After changing sample code of post2.php my code looks like this



<?php
// Connect to MySQL database
include ("dbconnection.php");

$page = 1; // The current page
$sortname = 'name'; // Sort column
$sortorder = 'asc'; // Sort order
$qtype = ''; // Search column
$query = ''; // Search string
// Get posted data
if (isset($_POST['page'])) {
$page = mysql_real_escape_string($_POST['page']);
}
if (isset($_POST['sortname'])) {
$sortname = mysql_real_escape_string($_POST['sortname']);
}
if (isset($_POST['sortorder'])) {
$sortorder = mysql_real_escape_string($_POST['sortorder']);
}
if (isset($_POST['qtype'])) {
$qtype = mysql_real_escape_string($_POST['qtype']);
}
if (isset($_POST['query'])) {
$query = mysql_real_escape_string($_POST['query']);
}
$rp =10;
if (isset($_POST['rp'])) {
$rp = mysql_real_escape_string($_POST['rp']);
}
// Setup sort and search SQL using posted data
$sortSql = "order by $sortname $sortorder";
$searchSql = ($qtype != '' && $query != '') ? "where $qtype =
'$query'" : '';
// Get total count of records
$sql = "select count(*)
from `ressult_`
$searchSql";
$result = runQuery($sql);
$row = mysql_fetch_array($result);
$total = $row[0];
// Setup paging SQL
$pageStart = ($page-1)*$rp;
$limitSql = "limit $pageStart, $rp";
// Return JSON data
$data = array();
$data['page'] = $page;
$data['total'] = $total;
$data['rows'] = array();
$sql = "select *
from `ressult_`
$searchSql
$sortSql
$limitSql";
$results = runQuery($sql);

while ($row = mysql_fetch_assoc($results)) {
$data['rows'][] = array(
'id' => $row['seatNo'],
'cell' => array( $row['seatNo'], $row['name'],
$row['fname'],
$row['inwords'], $row['marks']
)
);
}


echo json_encode($data);


?>
//////////////////////// and getting output like


{"page":1,"total":"31","rows":[{"id":"2K8\/BBA\/08","cell":["2K8\/BBA\/
08","AMIR HAMZA","KHALID","Seventy Four","74"]},{"id":"2K8\/BBA\/
09","cell":["2K8\/BBA\/09","AMNA","ABDUL GHAFOOR","Sixty Five","65"]},
{"id":"2K8\/BBA\/10","cell":["2K8\/BBA\/10","ASIF ALI","GHULAM
RASOOL","Twenty Eight","28"]},{"id":"2K8\/BBA\/15","cell":["2K8\/BBA\/
15","GHULAM MURTAZA","GHULAM MUSTAFA","Eight only ","8"]},{"id":"2K8\/
BBA\/19","cell":["2K8\/BBA\/19","IMRAN ALI","MUHAMMAD ANWAR","Seventy
Five","75"]},{"id":"2K8\/BBA\/21","cell":["2K8\/BBA\/21","JEHANSHER
KHAN","MUHAMMAD IQBAL SHAH","Seventy Four","74"]},{"id":"2K8\/BBA\/
22","cell":["2K8\/BBA\/22","JUMAN SHAH","HUSSAIN SHAH","Seventy
Five","75"]},{"id":"2K8\/BBA\/23","cell":["2K8\/BBA\/23","KASHIF
ASHRAF","MUHAMMAD ASHRAF","Seventy Five","75"]},{"id":"2K8\/BBA\/
24","cell":["2K8\/BBA\/24","KHURRAM ALI","ABDUL GHAFFAR","Eighty
Eight","88"]},{"id":"2K8\/BBA\/25","cell":["2K8\/BBA\/25","KIRAN
WARIS","GHULAM WARIS","Sixty Seven","67"]}]}



{
id: "2K8/BBA/23",
cell: [
"2K8/BBA/23",
"KASHIF ASHRAF",
"MUHAMMAD ASHRAF",
"Seventy Five",
"75"
]
}

here after cell: I am getting [ bracket but in http://flexigrid.info/post2.php
example we have { bracket.
please guide where is error
Reply all
Reply to author
Forward
0 new messages