<?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: Nav Bar Search Predicate Construction</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction</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/nav-bar-search-predicate-construction/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Tq46 on Nav Bar Search Predicate Construction</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3833</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3833</guid>
        	        	<description><![CDATA[<p>Thanks for the reply, Tony.</p>
<p>The grid is being presented as read-only, so no injection worries, but the user form that feeds it uses something like:</p>
<p>$query = sprintf ("<br />INSERT INTO `my_table` (`id`,`a`,`b`)<br />VALUES<br />(&#39;%d&#39;,&#39;%s&#39;,&#39;%s&#39;)",<br />$id,<br />mysql_real_escape_string($_POST[&#39;a&#39;], $conn),<br />mysql_real_escape_string($_POST[&#39;b&#39;], $conn)<br />);</p>
</p>
<p>Otherwise, this seems to work fine:</p>
<p>if ($_GET[&#39;_search&#39;] == "true") {</p>
<p>$where_clause_1 = "";</p>
<p>$ss = $_GET[&#39;searchString&#39;];</p>
<p>$eq = "= &#39;".$ss."&#39;";<br />$ne = "&#60;&#62; &#39;".$ss."&#39;";<br />$lt = "&#60; &#39;".$ss."&#39;";<br />$le = "&#60;= &#39;".$ss."&#39;";<br />$gt = "&#62; &#39;".$ss."&#39;";<br />$ge = "&#62;= &#39;".$ss."&#39;";<br />$bw = "LIKE &#39;".$ss."%&#39;";<br />$ew = "LIKE &#39;%".$ss."&#39;";<br />$cn = "LIKE &#39;%".$ss."%&#39;";<br />$ge = "&#62;= ".$ss;</p>
<p>$search_ar = array(<br />&#39;eq&#39; =&#62; $eq, &#39;ne&#39; =&#62; $ne, &#39;lt&#39; =&#62; $lt, &#39;le&#39; =&#62; $le, &#39;gt&#39; =&#62; $gt,<br />&#39;ge&#39; =&#62; $ge, &#39;bw&#39; =&#62; $bw, &#39;ew&#39; =&#62; $ew, &#39;cn&#39; =&#62; $cn<br />);</p>
<p>$where_clause_2 = "<br />WHERE `".$_GET[&#39;searchField&#39;]."` ".$search_ar[$_GET[&#39;searchOper&#39;]]."<br />";</p>
<p>} else {<br />$where_clause_1 = "";<br />$where_clause_2 = "";<br />}</p>
</p>
<p>-Gary (aka Tq46)</p>
]]></description>
        	        	<pubDate>Mon, 05 Jan 2009 17:31:33 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Nav Bar Search Predicate Construction</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3809</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3809</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>The warrning is that the posted data must be checked deeper to prevent SQL injection. By exmple if you expect a integer data (when it is posted) it is a good idea to do: (integer)$fldata. More about SQL injection you can find on the web.</p>
<p>Yes the search is only by one field only. You can use session variable to to make it multiple.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 05 Jan 2009 02:33:45 +0200</pubDate>
        </item>
        <item>
        	<title>Tq46 on Nav Bar Search Predicate Construction</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3764</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/nav-bar-search-predicate-construction#p3764</guid>
        	        	<description><![CDATA[<p>First off, congratulations Tony, nice plug-in!</p>
<p>A few of your demo files (e.g., <em>server.php</em>) have warning comments regarding the way the SQL WHERE clause variable ($wh) is constructed - for demo purposes only, it says. Are you refering only to that, or all the way through the SWITCH statements?</p>
<p>Also, could you be more specific and cite what&#39;s wrong with it, or perhaps better, what would properly take its place?</p>
<p>Sorry, I should be more specific myself: I&#39;m trying to get the <em>Find Records</em> to work from the Navigation bar. I got the impression from the documentation that the search was based on the subset of records that were displayed in the table, not a new query against my database.</p>
<p>Thanks</p>
<p>(Here&#39;s an excerpt from <em>server.php</em>):</p>
<p>// search options<br />// IMPORTANT NOTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br />// this type of constructing is not recommendet<br />// it is only for demonstration<br />//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!<br />$wh = "";<br />$searchOn = Strip($_REQUEST[&#39;_search&#39;]);<br />if($searchOn==&#39;true&#39;) {<br />&#160;&#160;&#160; $fld = Strip($_REQUEST[&#39;searchField&#39;]);<br />&#160;&#160;&#160; if( $fld==&#39;id&#39; &#124;&#124; $fld ==&#39;invdate&#39; &#124;&#124; $fld==&#39;name&#39; &#124;&#124; $fld==&#39;amount&#39; &#124;&#124; $fld==&#39;tax&#39; &#124;&#124; $fld==&#39;total&#39; &#124;&#124; $fld==&#39;note&#39; ) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fldata = Strip($_REQUEST[&#39;searchString&#39;]);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $foper = Strip($_REQUEST[&#39;searchOper&#39;]);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; // costruct where<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " AND ".$fld;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; switch ($foper) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "bw":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fldata .= "%";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " LIKE &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "eq":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " = ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " = &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "ne":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60;&#62; ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60;&#62; &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "lt":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60; ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60; &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "le":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60;= ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#60;= &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "gt":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#62; ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#62; &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "ge":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(is_numeric($fldata)) {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#62;= ".$fldata;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " &#62;= &#39;".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "ew":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " LIKE &#39;%".$fldata."&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; case "ew":<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh .= " LIKE &#39;%".$fldata."%&#39;";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; default :<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $wh = "";<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }<br />}<br />//echo $fld." : ".$wh;<br />// connect to the database</p>
<p><img class="spSmiley" style="margin:0" title="Smile" src="/blog/wp-content/plugins/simple-forum/tinymce/plugins/emotions/img/smiley-smile.gif" border="0" alt="Smile" /></p>
]]></description>
        	        	<pubDate>Wed, 31 Dec 2008 01:06:11 +0200</pubDate>
        </item>
</channel>
</rss>