<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Data missing from table. php file is not been called!</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>coolmanlg on Data missing from table. php file is not been called!</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20923</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20923</guid>
        	        	<description><![CDATA[<p>I hope this helps some one. I was able to solve the problem by passing the query string to the url: e.g.</p>
</p>
<p>url: "example.php?page=1&#38;start=0&#38;rows=10&#38;sidx=1&#38;sord=desc",</p>
</p>
<p>This was not obvious in the example documentation.</p>
]]></description>
        	        	<pubDate>Sat, 20 Nov 2010 11:46:57 +0200</pubDate>
        </item>
        <item>
        	<title>coolmanlg on Data missing from table. php file is not been called!</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20921</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20921</guid>
        	        	<description><![CDATA[<p>I have been trying to debug the problem using firebug and in I saw the url is set to "http://localhost/jgrid/jgrid.html" instead of "example.php" How do I change this please?&#160;</p>
]]></description>
        	        	<pubDate>Sat, 20 Nov 2010 03:52:04 +0200</pubDate>
        </item>
        <item>
        	<title>coolmanlg on Data missing from table. php file is not been called!</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20910</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/data-missing-from-table-php-file-is-not-been-called#p20910</guid>
        	        	<description><![CDATA[<p>Hell all,</p>
<p>I have downloaded the plugin and followed the setup instructions but it doesn&#39;t connect to the php file hence the table is empty without data.&#160;</p>
</p>
<p>Html file:</p>
<p>&#60;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&#62;</p>
<p>&#60;html&#62;</p>
<p>&#60;head&#62;<img class="spSmiley" style="margin:0" title="Confused" src="/blog/wp-content/forum-smileys/sf-confused.gif" alt="Confused" /></p>
<p>&#60;title&#62;&#60;/title&#62;</p>
<p>&#60;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.8.6.custom.css" /&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" /&#62;</p>
<p>&#60;style&#62;</p>
<p>html, body {</p>
<p>margin: 0;</p>
<p>padding: 0;</p>
<p>font-size: 75%;</p>
<p>}</p>
<p>&#60;/style&#62;</p>
</p>
<p>&#60;script src="js/jquery-1.4.2.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(function(){</p>
<p>$("#list").jqGrid({</p>
<p>datatype: &#39;xml&#39;,</p>
<p>url:&#39;example.php&#39;,</p>
<p>mtype: &#39;GET&#39;,</p>
<p>colNames:[&#39;Inv No&#39;,&#39;Date&#39;, &#39;Amount&#39;,&#39;Tax&#39;,&#39;Total&#39;,&#39;Notes&#39;],</p>
<p>colModel :[</p>
<p>{name:&#39;invid&#39;, index:&#39;invid&#39;, width:55},</p>
<p>{name:&#39;invdate&#39;, index:&#39;invdate&#39;, width:90},</p>
<p>{name:&#39;amount&#39;, index:&#39;amount&#39;, width:80, align:&#39;right&#39;},</p>
<p>{name:&#39;tax&#39;, index:&#39;tax&#39;, width:80, align:&#39;right&#39;},</p>
<p>{name:&#39;total&#39;, index:&#39;total&#39;, width:80, align:&#39;right&#39;},</p>
<p>{name:&#39;note&#39;, index:&#39;note&#39;, width:150, sortable:false}</p>
<p>],</p>
<p>pager: &#39;#pager&#39;,</p>
<p>rowNum:10,</p>
<p>rowList:[10,20,30],</p>
<p>sortname: &#39;invid&#39;,</p>
<p>sortorder: &#39;desc&#39;,</p>
<p>viewrecords: true,</p>
<p>caption: &#39;My first grid&#39;</p>
<p>});</p>
<p>});</p>
<p>&#60;/script&#62;</p>
<p>&#60;/head&#62;</p>
<p>&#60;body&#62;</p>
<p>&#60;table id="list"&#62;&#60;/table&#62;</p>
<p>&#60;div id="pager"&#62;&#60;/div&#62;</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
</p>
<p>PHP file:</p>
</p>
<p>&#60;?php</p>
<p>//include the information needed for the connection to MySQL data base server.</p>
<p>// we store here username, database and password</p>
<p>include("dbconfig.php");</p>
</p>
<p>// to the url parameter are added 4 parameters as described in colModel</p>
<p>// we should get these parameters to construct the needed query</p>
<p>// Since we specify in the options of the grid that we will use a GET method</p>
<p>// we should use the appropriate command to obtain the parameters.</p>
<p>// In our case this is $_GET. If we specify that we want to use post</p>
<p>// we should use $_POST. Maybe the better way is to use $_REQUEST, which</p>
<p>// contain both the GET and POST variables. For more information refer to php documentation.</p>
<p>// Get the requested page. By default grid sets this to 1.</p>
<p>$page = $_GET[&#39;page&#39;];</p>
</p>
<p>// get how many rows we want to have into the grid - rowNum parameter in the grid</p>
<p>$limit = $_GET[&#39;rows&#39;];</p>
<p>echo $limit;</p>
</p>
<p>// get index row - i.e. user click to sort. At first time sortname parameter -</p>
<p>// after that the index from colModel</p>
<p>$sidx = $_GET[&#39;sidx&#39;];</p>
</p>
<p>// sorting order - at first time sortorder</p>
<p>$sord = $_GET[&#39;sord&#39;];</p>
</p>
<p>// if we not pass at first time index use the first column for the index or what you want</p>
<p>if(!$sidx) $sidx =1;</p>
</p>
<p>// connect to the MySQL database server</p>
<p>$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());</p>
</p>
<p>// select the database</p>
<p>mysql_select_db($database) or die("Error connecting to db.");</p>
</p>
<p>// calculate the number of rows for the query. We need this for paging the result</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM invheader");</p>
<p>$row = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$count = $row[&#39;count&#39;];</p>
</p>
<p>// calculate the total pages for the query</p>
<p>if( $count &#62; 0 &#38;&#38; $limit &#62; 0) {</p>
<p>$total_pages = ceil($count/$limit);</p>
<p>} else {</p>
<p>$total_pages = 0;</p>
<p>}</p>
</p>
<p>// if for some reasons the requested page is greater than the total</p>
<p>// set the requested page to total page</p>
<p>if ($page &#62; $total_pages) $page=$total_pages;</p>
</p>
<p>// calculate the starting position of the rows</p>
<p>$start = $limit*$page - $limit;</p>
</p>
<p>// if for some reasons start position is negative set it to 0</p>
<p>// typical case is that the user type 0 for the requested page</p>
<p>if($start &#60;0) $start = 0;</p>
</p>
<p>// the actual query for the grid data</p>
<p>$SQL = "SELECT invid, invdate, amount, tax,total, note FROM invheader ORDER BY $sidx $sord LIMIT $start , $limit";</p>
<p>echo $SQL;</p>
</p>
<p>$result = mysql_query( $SQL ) or die("Couldn&#39;t execute query.".mysql_error());</p>
</p>
<p>// we should set the appropriate header information. Do not forget this.</p>
<p>header("Content-type: text/xml;charset=utf-8");</p>
</p>
<p>$s = "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&#62;";</p>
<p>$s .=  "&#60;rows&#62;";</p>
<p>$s .= "&#60;page&#62;".$page."&#60;/page&#62;";</p>
<p>$s .= "&#60;total&#62;".$total_pages."&#60;/total&#62;";</p>
<p>$s .= "&#60;records&#62;".$count."&#60;/records&#62;";</p>
</p>
<p>// be sure to put text data in CDATA</p>
<p>while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>$s .= "&#60;row id=&#39;". $row[&#39;invid&#39;]."&#39;&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;invid&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;invdate&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;amount&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;tax&#39;]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[&#39;total&#39;]."&#60;/ceecho phpinfo()ll&#62;";</p>
<p>$s .= "&#60;cell&#62;&#60;![CDATA[". $row[&#39;note&#39;]."]]&#62;&#60;/cell&#62;";</p>
<p>$s .= "&#60;/row&#62;";</p>
<p>}</p>
<p>$s .= "&#60;/rows&#62;";</p>
</p>
<p>?&#62;</p>
</p>
<p>What did I miss please?<img class="spSmiley" style="margin:0" title="Confused" src="/blog/wp-content/forum-smileys/sf-confused.gif" alt="Confused" /></p>
<p>
<!--         html, body {             margin: 0;             padding: 0;             font-size: 75%;         }      --> <!--             $(function(){               $("#list").jqGrid({                 datatype: &#39;xml&#39;,                 url:&#39;example.php&#39;,                 mtype: &#39;GET&#39;,                 colNames:[&#39;Inv No&#39;,&#39;Date&#39;, &#39;Amount&#39;,&#39;Tax&#39;,&#39;Total&#39;,&#39;Notes&#39;],                 colModel :[                   {name:&#39;invid&#39;, index:&#39;invid&#39;, width:55},                   {name:&#39;invdate&#39;, index:&#39;invdate&#39;, width:90},                   {name:&#39;amount&#39;, index:&#39;amount&#39;, width:80, align:&#39;right&#39;},                   {name:&#39;tax&#39;, index:&#39;tax&#39;, width:80, align:&#39;right&#39;},                   {name:&#39;total&#39;, index:&#39;total&#39;, width:80, align:&#39;right&#39;},                   {name:&#39;note&#39;, index:&#39;note&#39;, width:150, sortable:false}                 ],                 pager: &#39;#pager&#39;,                 rowNum:10,                 rowList:[10,20,30],                 sortname: &#39;invid&#39;,                 sortorder: &#39;desc&#39;,                 viewrecords: true,                 caption: &#39;My first grid&#39;               });             });      // --></p>
]]></description>
        	        	<pubDate>Fri, 19 Nov 2010 15:26:00 +0200</pubDate>
        </item>
</channel>
</rss>