<?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: Dynamic SQL for jqgrid</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/dynamic-sql-for-jqgrid</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/dynamic-sql-for-jqgrid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>byujensen on Dynamic SQL for jqgrid</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamic-sql-for-jqgrid#p25024</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamic-sql-for-jqgrid#p25024</guid>
        	        	<description><![CDATA[<p>I am using Apache/PHP/MySQL web server and I&#39;m trying to load a grid. I followed the demo to get a working grid with my data, and I have an index.php page that simply includes the maininteractionsgrid.php (pasted below). Now I would like to be able to add a WHERE statement to the sql based on a variable that has already been assigned in the index.php. I can get the WHERE statement to work if I specify a fixed number (i.e. siteid=10), but for some reason it won&#39;t work if I specify the variable (i.e. siteid=$siteid... $siteid has already been set to 10). Can someone PLEASE help me figure out why my code below isn&#39;t working? I have tried searching all over online and can&#39;t find anything as to why my code isn&#39;t going through. All I would like to do is get only the records for a certain site based on a passed variable, $siteid. Any help would be greatly appreciated. Thanks.</p>
</p>
<p>&#60;?php</p>
<p>require_once &#39;jqinteractionsconfig.php&#39;;</p>
<p>// include the jqGrid Class</p>
<p>require_once ABSPATH."php/jqGrid.php";</p>
<p>// include the driver class</p>
<p>require_once ABSPATH."php/jqGridPdo.php";</p>
<p>// Connection to the server</p>
<p>$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);</p>
<p>// Tell the db that we use utf-8</p>
<p>$conn-&#62;query("SET NAMES utf8");</p>
</p>
<p>// Create the jqGrid instance</p>
<p>$grid = new jqGridRender($conn);</p>
<p>// Write the SQL Query</p>
<p><strong>$mysql = "SELECT InteractionID, InteractionDateTime, ContactID, ContactedBy,&#160;InteractionType, Notes, SiteID&#160;FROM tbl_interactions&#160;WHERE SiteID=$siteid";</strong></p>
<p>$grid-&#62;SelectCommand = $mysql;</p>
<p>// Set the table to where you add the data</p>
<p>$grid-&#62;table = &#39;tbl_interactions&#39;;</p>
<p>// Set output format to json</p>
<p>$grid-&#62;dataType = &#39;json&#39;;</p>
<p>// Let the grid create the model</p>
<p>$grid-&#62;setColModel();</p>
<p>// Set the url from where we obtain the data</p>
<p>$grid-&#62;setUrl(&#39;maininteractionsgrid.php&#39;);</p>
<p>$grid-&#62;addCol(array(</p>
<p>&#160;&#160;&#160; "name"=&#62;"Actions",</p>
<p>&#160;&#160;&#160; "formatter"=&#62;"actions",</p>
<p>&#160;&#160;&#160; "editable"=&#62;false,</p>
<p>&#160;&#160;&#160; "sortable"=&#62;false,</p>
<p>&#160;&#160;&#160; "resizable"=&#62;false,</p>
<p>&#160;&#160;&#160; "fixed"=&#62;true,</p>
<p>&#160;&#160;&#160; "width"=&#62;60,</p>
<p>&#160;&#160;&#160; "formatoptions"=&#62;array("keys"=&#62;true)</p>
<p>&#160;&#160;&#160; ), "first");</p>
<p>$grid-&#62;setColProperty(&#39;InteractionID&#39;, array("editable"=&#62;false));</p>
<p>// Set some grid options</p>
<p>$grid-&#62;setGridOptions(array(</p>
<p>&#160;&#160;&#160; "rowNum"=&#62;25,</p>
<p>&#160;&#160;&#160; "rowList"=&#62;array(25,50,75,100),</p>
<p>&#160;&#160;&#160; "sortname"=&#62;"InteractionID"</p>
<p>));</p>
<p>// Enjoy</p>
<p>$grid-&#62;renderGrid(&#39;#grid&#39;,&#39;#pager&#39;,true, null, null, true,true);</p>
<p>$conn = null;</p>
<p>?&#62;</p>
]]></description>
        	        	<pubDate>Sat, 29 Oct 2011 21:06:13 +0300</pubDate>
        </item>
</channel>
</rss>