<?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: Error when cretae jgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/discussion/error-when-cretae-jgrid</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/error-when-cretae-jgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>cnodom on Error when cretae jgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/discussion/error-when-cretae-jgrid#p22819</link>
        	<category>Discussion</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/discussion/error-when-cretae-jgrid#p22819</guid>
        	        	<description><![CDATA[<p>Couldn t execute query.You have an error in your SQL syntax; check the  manual that corresponds to your MySQL server version for the right  syntax to use near &#39;&#39; at line 1</p>
<p>-------------coding----------</p>
<p>&#60;html&#62;<br />&#60;body&#62;<br />&#60;table id="listdt" class="scroll"&#62;&#60;/table&#62;<br />&#60;div id="pagerdt" class="scroll" style="text-align:center;"&#62;&#60;/div&#62;<br />&#60;script src="datatype.js" type="text/javascript"&#62; &#60;/script&#62;</p>
<p>&#60;script&#62;<br />&#160;&#160; &#160;&#160;&#160; &#160;jQuery("#listdt").jqGrid({&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160; &#160;&#160;&#160; &#160;//url:&#39;server.php?q=2&#39;,<br />&#160;&#160; &#160;datatype : &#160;&#160; &#160;function&#160; (pdata) {<br />&#160;&#160; &#160;&#160;&#160; &#160;$.ajax({<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;url:&#39;server.php?q=2&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;data:pdata,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;dataType:"json",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;complete: function(jsondata,stat){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;if(stat=="success") {<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;var thegrid = jQuery("#listdt")[0];<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;thegrid.addJSONData(eval("("+jsondata.responseText+")"))<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;}<br />&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;},<br />&#160; &#160;&#160;&#160; &#160;colNames:[&#39;Inv No&#39;,&#39;Date&#39;, &#39;Client&#39;, &#39;Amount&#39;,&#39;Tax&#39;,&#39;Total&#39;,&#39;Notes&#39;],<br />&#160; &#160;&#160;&#160; &#160;colModel:[<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;id&#39;,index:&#39;id&#39;, width:55},<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:90},<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;name&#39;,index:&#39;name asc, invdate&#39;, width:100},<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;amount&#39;,index:&#39;amount&#39;, width:80, align:"right", editable:true,editrules:{number:true,minValue:100,maxValue:350}},<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;tax&#39;,index:&#39;tax&#39;, width:80, align:"right",editable:true,edittype:"select",editoptions:{value:"IN:InTime;TN:TNT;AR:ARAMEX"}},&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;total&#39;,index:&#39;total&#39;, width:80,align:"right",editable: true,edittype:"checkbox",editoptions: {value:"Yes:No"} },&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;note&#39;,index:&#39;note&#39;, width:150, sortable:false}&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160; &#160;&#160;&#160; &#160;],<br />&#160; &#160;&#160;&#160; &#160;rowNum:10,<br />&#160; &#160;&#160;&#160; &#160;rowList:[10,20,30],<br />&#160; &#160;&#160;&#160; &#160;imgpath: gridimgpath,<br />&#160; &#160;&#160;&#160; &#160;pager: jQuery(&#39;#pagerdt&#39;),<br />&#160; &#160;&#160;&#160; &#160;sortname: &#39;id&#39;,<br />&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160; sortorder: "desc",<br />&#160;&#160;&#160; caption:"Data type as function Example",<br />&#160;&#160;&#160; cellEdit: true<br />}).navGrid(&#39;#pagerdt&#39;,{edit:false,add:false,del:false});</p>
<p>&#60;/script&#62;<br />&#60;?php<br />&#160;&#160; &#160;&#160;&#160; &#160;$page = $_GET[&#39;page&#39;]; // get the requested page<br />$limit = $_GET[&#39;rows&#39;]; // get how many rows we want to have into the grid<br />$sidx = $_GET[&#39;sidx&#39;]; // get index row - i.e. user click to sort<br />$sord = $_GET[&#39;sord&#39;]; // get the direction<br />if(!$sidx) $sidx =1;<br />// connect to the database<br />$db = mysql_connect("localhost","root","")<br />or die("Connection Error: " . mysql_error());</p>
<p>mysql_select_db("testjquery") or die("Error conecting to db.");<br />$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.id=b.client_id");<br />$row = mysql_fetch_array($result,MYSQL_ASSOC);<br />$count = $row[&#39;count&#39;];</p>
<p>if( $count &#62;0 ) {<br />&#160;&#160; &#160;$total_pages = ceil($count/1);<br />} else {<br />&#160;&#160; &#160;$total_pages = 0;<br />}</p>
<p>if ($page &#62; $total_pages) $page=$total_pages;<br />$start = $limit*$page - $limit; // do not put $limit*($page - 1)<br />$SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";</p>
<p>$result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error());</p>
<p>$responce-&#62;page = $page;<br />$responce-&#62;total = $total_pages;<br />$responce-&#62;records = $count;<br />$i=0;<br />while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {<br />&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;id&#39;]=$row[id];<br />&#160;&#160;&#160; $responce-&#62;rows[$i][&#39;cell&#39;]=array($row[id],$row[invdate],$row[name],$row[amount],$row[tax],$row[total],$row[note]);<br />&#160;&#160;&#160; $i++;<br />}&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />echo json_encode($responce);</p>
<p>&#160;&#160; &#160;<br />?&#62;<br />&#60;/body&#62;<br />&#60;/html&#62;</p>
]]></description>
        	        	<pubDate>Sun, 17 Apr 2011 07:47:03 +0300</pubDate>
        </item>
</channel>
</rss>