<?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: jqgrid pager, php json file structure</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure</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/jqgrid-pager-php-json-file-structure/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>netpumber on jqgrid pager, php json file structure</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29012</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29012</guid>
        	        	<description><![CDATA[<p>I&#39;ve change a little the code but still have to change more..</p>
</p>
<pre class="lang-php prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit5912' value='Select Code' data-codeid='sfcode5912' /></p><div class='sfcode' id='sfcode5912'>     if(!$sidx) $sidx =1;
        $result = mysql_query("SELECT COUNT(*) AS count FROM logs");
        $row = mysql_fetch_array($result);
        $count = $row[&#39;count&#39;]; 

        if( $count &#62;0 ) {
            $total_pages = ceil($count/$limit);
        } else {
            $total_pages = 0;
        }

        if ($page &#62; $total_pages) $page=$total_pages;
        $start = $limit*$page - $limit;

        $pages_array = array("page"=&#62; $page , "total" =&#62; $total_pages , "records" =&#62; $count);


        array_push($return_array,$pages_array);

        // Getting data for jqGrid table

        $data =  mysql_query("SELECT * FROM logs ORDER BY log_id DESC");

        if(mysql_num_rows($data))
        {
            while($row = mysql_fetch_array($data)) 
            { 
                $row_array[&#39;rows&#39;][&#39;log_id&#39;] = $row[&#39;log_id&#39;];          
                $row_array[&#39;rows&#39;][&#39;ip&#39;] = $row[&#39;ip&#39;];
                $row_array[&#39;rows&#39;][&#39;hostname&#39;] = $row[&#39;host&#39;];
                $row_array[&#39;rows&#39;][&#39;log&#39;] = $row[&#39;input&#39;];
                $row_array[&#39;rows&#39;][&#39;date&#39;] = $row[&#39;date&#39;];

                array_push($return_array,$row_array);
            }   
        }

        echo json_encode($return_array);</div></pre>
]]></description>
        	        	<pubDate>Sat, 15 Jun 2013 23:41:36 +0300</pubDate>
        </item>
        <item>
        	<title>netpumber on jqgrid pager, php json file structure</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29011</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29011</guid>
        	        	<description><![CDATA[<p>No one can help me to fix this json output ?</p>
]]></description>
        	        	<pubDate>Sat, 15 Jun 2013 19:45:18 +0300</pubDate>
        </item>
        <item>
        	<title>netpumber on jqgrid pager, php json file structure</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29010</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-pager-php-json-file-structure#p29010</guid>
        	        	<description><![CDATA[<p>I have this php code for counting the number of pages</p>
<p>and retrieve data from database, but something is going wrong</p>
<p>with the pager as i can see.</p>
<p>Specifically i think that there is a problem with the json file structure.</p>
<p>Here is the php code:</p>
</p>
<pre class="default prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit9259' value='Select Code' data-codeid='sfcode9259' /></p><div class='sfcode' id='sfcode9259'>public function getLogsList($page,$limit,$sidx,$sord)
    {
        init_mysql();

        $return_array = array();
        $row_array = array();

        // Getting pages number (for jqGrid pager)

        if(!$sidx) $sidx =1;
        $result = mysql_query(&#34;SELECT COUNT(*) AS count FROM logs&#34;);
        $row = mysql_fetch_array($result);
        $count = $row[&#39;count&#39;]; 

        if( $count &#62;0 ) {
            $total_pages = ceil($count/$limit);
        } else {
            $total_pages = 0;
        }

        if ($page &#62; $total_pages) $page=$total_pages;
        $start = $limit*$page - $limit;

        $row_array[&#39;page&#39;] = $page;         
        $row_array[&#39;total&#39;] = $total_pages;
        $row_array[&#39;records&#39;] = $count;

        array_push($return_array,$row_array);

        // Getting data for jqGrid table

        $data =  mysql_query(&#34;SELECT * FROM logs ORDER BY log_id DESC&#34;);

        if(mysql_num_rows($data))
        {
            while($row = mysql_fetch_array($data)) 
            { 

                $row_array[&#39;log_id&#39;] = $row[&#39;log_id&#39;];          
                $row_array[&#39;ip&#39;] = $row[&#39;ip&#39;];
                $row_array[&#39;hostname&#39;] = $row[&#39;host&#39;];
                $row_array[&#39;log&#39;] = $row[&#39;input&#39;];
                $row_array[&#39;date&#39;] = $row[&#39;date&#39;];

                array_push($return_array,$row_array);
            }   
        }

        echo json_encode($return_array);
    }</div></pre>
</p>
<p>The json file looks like this :</p>
</p>
<pre class="default prettyprint prettyprinted"><p><input type='button' class='sfcodeselect' name='sfselectit8436' value='Select Code' data-codeid='sfcode8436' /></p><div class='sfcode' id='sfcode8436'>[{&#34;page&#34;:&#34;1&#34;,&#34;total&#34;:2,&#34;records&#34;:&#34;34&#34;},{&#34;page&#34;:&#34;1&#34;,&#34;total&#34;:2,&#34;records&#34;:&#34;34&#34;,&#34;log_id&#34;:&#34;108&#34;,&#34;ip&#34;:&#34;127.0.0.1&#34;,&#34;hostname&#34;:&#34;&#34;,&#34;log&#34;:&#34;having 1=1&#34;,&#34;date&#34;:&#34;09-06-2013 22:05:57&#34;},{&#34;page&#34;:&#34;1&#34;,&#34;total&#34;:2,&#34;records&#34;:&#34;34&#34;,&#34;log_id&#34;:&#34;107&#34;,&#34;ip&#34;:&#34;127.0.0.1&#34;,&#34;hostname&#34;:&#34;&#34;,&#34;log&#34;:&#34;//&#34;,&#34;date&#34;:&#34;09-06-2013 22:05:57&#34;},.....}]</div></pre>
</p>
<p>as you can see page , total and records are printed each time and</p>
<p>that why i think that something is going wrong with the structure of json file.</p>
</p>
<p>Is there any way to fix it ?</p>
</p>
<p>Thanks.</p>
]]></description>
        	        	<pubDate>Sat, 15 Jun 2013 12:22:04 +0300</pubDate>
        </item>
</channel>
</rss>