<?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: Json Data not show in table</title>
	<link>http://www.trirand.com/blog/?page_id=393/discussion/json-data-not-show-in-table</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/discussion/json-data-not-show-in-table/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>brandonkirsch on Json Data not show in table</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/json-data-not-show-in-table#p26575</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/json-data-not-show-in-table#p26575</guid>
        	        	<description><![CDATA[<p>I can&#39;t see the definition of Reuniao::listar, but there is a very high chance that your code contains SQL injection vulnerabilities, especially around the page, limit and sord parameters. &#160;You cannot simply mysql_escape some of these parameters and remain protected.</p>
</p>
<p>Second, you are building the JSON object by hand, and improperly escaping data (quotes within your values) that would lead to invalid JSON syntax. &#160;Instead of:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit165' value='Select Code' data-codeid='sfcode165' /></p>
<div class='sfcode' id='sfcode165'>
<p>foreach ($linha as $l):</p>
<p>if( $count == count($linha) ) {</p>
<p>$saida .= &#39;{ &#34;id&#34;: &#34;&#39; . $l[&#39;cod_reuniao&#39;] . &#39;&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] }&#39;;</p>
<p>} else {</p>
<p>$saida .= &#39;{ &#34;id&#34;: &#34;&#39; . $l[&#39;cod_reuniao&#39;] . &#39;&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] },&#39;;</p>
<p>}</p>
</div>
<p>You should try using json_encode to do all of the PHP array to JSON object conversion:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8292' value='Select Code' data-codeid='sfcode8292' /></p>
<div class='sfcode' id='sfcode8292'>
<p>$saida = array();</p>
<p>foreach ($linha as $l):</p>
<p>if( $count == count($linha) ) {</p>
<p>$saida[] = array(&#39;id&#39; =&#62; $l[&#39;code_reuniao&#39;], &#39;cell&#39; =&#62; array(&#39;teste&#39;, &#39;teste&#39;, &#39;teste, &#39;teste&#39;, etc....));</p>
<p>}&#160;else {&#160;</p>
<p>$saida[] = array(&#39;id&#39; =&#62; $l[&#39;cod_reunaio&#39;], &#39;cell&#39; =&#62; array(&#39;teste&#39;, &#39;teste&#39;, &#39;testes&#39;, etc...));</p>
<p>}</p>
<p>endforeach;</p>
<p>echo json_encode($saida);</p>
</div>
]]></description>
        	        	<pubDate>Fri, 11 May 2012 21:30:25 +0300</pubDate>
        </item>
        <item>
        	<title>destrutorx on Json Data not show in table</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/json-data-not-show-in-table#p26507</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/json-data-not-show-in-table#p26507</guid>
        	        	<description><![CDATA[<p>Hello people.</p>
<p>I&#39;m using PHP to load a JSON to JQGRID but the table is coming empty. I have printed the PHP result and I can&#39;t find the error.</p>
</p>
<p>My data (created via PHP):</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit4407' value='Select Code' data-codeid='sfcode4407' /></p>
<div class='sfcode' id='sfcode4407'>{ &#34;page&#34;: &#34;&#34;, &#34;total&#34;: &#34;0&#34;, &#34;records&#34;: &#34;3&#34;, &#34;rows&#34;: [{ &#34;id&#34;: &#34;1&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] },{ &#34;id&#34;: &#34;3&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] },{ &#34;id&#34;: &#34;2&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] }]}</div>
<p>My PHP code:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7509' value='Select Code' data-codeid='sfcode7509' /></p>
<div class='sfcode' id='sfcode7509'>
<p>$conexao = new Conexao;</p>
</p>
<p>$code &#160;= mysql_escape_string($_GET[&#39;code&#39;]);</p>
<p>$page &#160;= mysql_escape_string($_GET[&#39;page&#39;]);</p>
<p>$limit = mysql_escape_string($_GET[&#39;rows&#39;]);</p>
<p>$sidx &#160;= mysql_escape_string($_GET[&#39;sidx&#39;]);</p>
<p>$sord &#160;= mysql_escape_string($_GET[&#39;sord&#39;]);</p>
</p>
<p>if( !$sidx ) { $sidx = 1; }</p>
</p>
<p>$contador = Reuniao::total_listar($code, true, &#39;Ativo&#39;); // select data count in mysql table</p>
</p>
<p>if( $contador &#62; 0 ) {</p>
<p>$total_pages = ceil($contador/$limit);</p>
<p>} else $total_pages = 0;</p>
</p>
<p>if($page &#62; $total_pages) { $page = $total_pages; }</p>
</p>
<p>$start = $limit * $page &#8211; $limit;</p>
</p>
<p>$linha = Reuniao::listar($code, false, NULL, $sidx, $sord, $start, $limit); // select data in mysql table</p>
</p>
<p>$saida = &#39;{ &#34;page&#34;: &#34;&#39; . $page . &#39;&#34;, &#34;total&#34;: &#34;&#39; . $total_pages . &#39;&#34;, &#34;records&#34;: &#34;&#39; . $contador . &#39;&#34;, &#34;rows&#34;: [&#39;;</p>
<p>$count = 1;</p>
</p>
<p>foreach ($linha as $l):</p>
<p>if( $count == count($linha) ) {</p>
<p>$saida .= &#39;{ &#34;id&#34;: &#34;&#39; . $l[&#39;cod_reuniao&#39;] . &#39;&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] }&#39;;</p>
<p>} else {</p>
<p>$saida .= &#39;{ &#34;id&#34;: &#34;&#39; . $l[&#39;cod_reuniao&#39;] . &#39;&#34;, &#34;cell&#34;: [&#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;, &#34;teste&#34;] },&#39;;</p>
<p>}</p>
<p>$count++;</p>
<p>endforeach;</p>
</p>
<p>$saida .= &#39;]}&#39;;</p>
</p>
<p>echo $saida;</p>
</div>
<p>Can anyone help me to see what is wrong here?</p></p>
]]></description>
        	        	<pubDate>Thu, 03 May 2012 21:00:20 +0300</pubDate>
        </item>
</channel>
</rss>