Tony, I can't seem to get jqGrid to work. I've looked at all the examples but I must be missing something somewhere. I would appreciate if you would take a look at my PHP.
include("dbconfig.php"); include("JSON.php"); $json = new Services_JSON(); $examp = $_GET["q"]; $page = $_GET['page']; $limit = $_GET['rows']; $sidx = $_GET['sidx']; $sord = $_GET['sord']; if(!$sidx) $sidx =1; $db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error conecting to db."); switch ($examp) { case 1: $result = mysql_query("SELECT COUNT(*) AS count FROM scoremain a"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; 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) if ($start<0) $start = 0; $SQL = "SELECT id, user, score, favgame, rank FROM scoremain ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) { header("Content-type: application/xhtml+xml;charset=utf-8"); } else { header("Content-type: text/xml;charset=utf-8"); } $et = ">"; echo "<?xml version='1.0' encoding='utf-8'?$et\n"; echo "<rows>"; echo "<page>".$page."</page>"; echo "<total>".$total_pages."</total>"; echo "<records>".$count."</records>"; // be sure to put text data in CDATA while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { echo "<row id='". $row[id]."'>"; echo "<cell>". $row[rank]."</cell>"; echo "<cell><![CDATA[". $row[user]."]]></cell>"; echo "<cell>". $row[score]."</cell>"; echo "<cell><![CDATA[". $row[favgame]."]]></cell>"; echo "</row>"; } echo "</rows>"; break; case 2: $result = mysql_query("SELECT COUNT(*) AS count FROM scoremain"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; 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) if ($start<0) $start = 0; $SQL = "SELECT id, user, score, favgame, rank FROM scoremain ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn’t execute query.".mysql_error()); $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[id]; $responce->rows[$i]['cell']=array($row[rank],$row[user], $row[score],$row[favgame]); $i++; } echo $json->encode($responce); // coment if php 5 echo json_encode($responce); break; } This is uploaded at http://xeolife.com/dbtest/. Thanks.