<?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: Ask: Integrated Search Toolbar-&#62;PHP-Mysql syntax</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax</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/ask-integrated-search-toolbar-php-mysql-syntax/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>Candra on Ask: Integrated Search Toolbar-&#62;PHP-Mysql syntax</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13967</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13967</guid>
        	        	<description><![CDATA[<p>To newperson,</p>
<p>Thx for your explanation. But I still have problem on it.</p>
<p>
<!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:view> <w:zoom>0</w:zoom> <w:compatibility> <w:breakwrappedtables></w:breakwrappedtables> <w:snaptogridincell></w:snaptogridincell> <w:wraptextwithpunct></w:wraptextwithpunct> <w:useasianbreakrules></w:useasianbreakrules> </w:compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel> </w:worddocument> </xml><![endif]--></p>
<p>&#60;!--  /* Font Definitions */  @font-face 	{font-family:Calibri; 	mso-font-alt:"Century Gothic"; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:Calibri; 	mso-fareast-font-family:Calibri; 	mso-bidi-font-family:"Times New Roman";} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 90.0pt 72.0pt 90.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&#62;</p>
<p><!--[if gte mso 10]>




<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>




<![endif]--></p>
<p class="MsoNormal"><strong>I can not find the strip function on php manual but I find stripslashes, is it similar?because if i use Strip function it causes error.<br /></strong></p>
<p>
<!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:view> <w:zoom>0</w:zoom> <w:compatibility> <w:breakwrappedtables></w:breakwrappedtables> <w:snaptogridincell></w:snaptogridincell> <w:wraptextwithpunct></w:wraptextwithpunct> <w:useasianbreakrules></w:useasianbreakrules> </w:compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel> </w:worddocument> </xml><![endif]--></p>
<p>&#60;!--  /* Font Definitions */  @font-face 	{font-family:Calibri; 	mso-font-alt:"Century Gothic"; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:Calibri; 	mso-fareast-font-family:Calibri; 	mso-bidi-font-family:"Times New Roman";} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 90.0pt 72.0pt 90.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&#62;</p>
<p><!--[if gte mso 10]>




<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>




<![endif]--></p>
<p class="MsoNormal"><strong>if i run PHP-MYSQL example code with IE, the code do not work,could you help me find where is my error lies?</strong></p>
<p>
<!--[if gte mso 9]><xml> <w:worddocument> <w:view>Normal</w:view> <w:zoom>0</w:zoom> <w:compatibility> <w:breakwrappedtables></w:breakwrappedtables> <w:snaptogridincell></w:snaptogridincell> <w:wraptextwithpunct></w:wraptextwithpunct> <w:useasianbreakrules></w:useasianbreakrules> </w:compatibility> <w:browserlevel>MicrosoftInternetExplorer4</w:browserlevel> </w:worddocument> </xml><![endif]--></p>
<p>&#60;!--  /* Font Definitions */  @font-face 	{font-family:Calibri; 	mso-font-alt:"Century Gothic"; 	mso-font-charset:0; 	mso-generic-font-family:swiss; 	mso-font-pitch:variable; 	mso-font-signature:-1610611985 1073750139 0 0 159 0;}  /* Style Definitions */  p.MsoNormal, li.MsoNormal, div.MsoNormal 	{mso-style-parent:""; 	margin-top:0cm; 	margin-right:0cm; 	margin-bottom:10.0pt; 	margin-left:0cm; 	line-height:115%; 	mso-pagination:widow-orphan; 	font-size:11.0pt; 	font-family:Calibri; 	mso-fareast-font-family:Calibri; 	mso-bidi-font-family:"Times New Roman";} @page Section1 	{size:612.0pt 792.0pt; 	margin:72.0pt 90.0pt 72.0pt 90.0pt; 	mso-header-margin:36.0pt; 	mso-footer-margin:36.0pt; 	mso-paper-source:0;} div.Section1 	{page:Section1;} --&#62;</p>
<p><!--[if gte mso 10]>




<style>
 /* Style Definitions */
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>




<![endif]--></p>
<p class="MsoNormal">&#60;?php</p>
<p class="MsoNormal">include &#39;config/connect.php&#39;;</p>
<p class="MsoNormal"><span>&#160;</span>$page = $_REQUEST[&#39;page&#39;]; // get the requested page</p>
<p class="MsoNormal">$limit = $_REQUEST[&#39;rows&#39;]; // get how many rows we want to have into the grid</p>
<p class="MsoNormal">$sidx = $_REQUEST[&#39;sidx&#39;]; // get index row - i.e. user click to sort</p>
<p class="MsoNormal">$sord = $_REQUEST[&#39;sord&#39;]; // get the direction</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal">if(!$sidx) $sidx =1;</p>
<p class="MsoNormal">$wh = "";</p>
<p class="MsoNormal">$searchOn = stripslashes($_REQUEST[&#39;_search&#39;]);</p>
<p class="MsoNormal">if($searchOn==&#39;true&#39;) { $sarr = Strip($_REQUEST);</p>
<p class="MsoNormal">foreach( $sarr as $k=&#62;$v) {</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>switch ($k) {</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;id&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;name&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;address&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;phone&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;fax&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;email&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$wh .= " AND ".$k." LIKE &#39;".$v."%&#39;";</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>break;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>case &#39;total&#39;:</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$wh .= " AND ".$k." = ".$v;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>break; } }</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}</p>
<p class="MsoNormal">//echo $wh;</p>
<p class="MsoNormal">switch ($examp) { case 1: $result = mysqli_query($link, "SELECT COUNT(*) AS count FROM table WHERE ".$wh);</p>
<p class="MsoNormal">$row = mysqli_fetch_array($result,MYSQLI_ASSOC);</p>
<p class="MsoNormal">$count = $row[&#39;count&#39;];</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// calculate the total pages for the query</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>if( $count &#62;0 ) {</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$total_pages = ceil($count/$limit);</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} else {</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$total_pages = 0;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>}</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// if for some reasons the requested page is greater than the total</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// set the requested page to total page</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span lang="FR">if ($page &#62; $total_pages) $page=$total_pages;</span></p>
<p class="MsoNormal"><span lang="FR"><span>&#160;</span></span></p>
<p class="MsoNormal"><span lang="FR"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span>// calculate the starting position of the rows</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$start = $limit*$page - $limit;</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// if for some reasons start position is negative set it to 0</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// typical case is that the user type 0 for the requested page</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>if($start &#60; 0) $start = 0;</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>// the actual query for the grid data</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$SQL = "SELECT * FROM table WHERE".$wh." ORDER BY ".$sidx." ".$sord. " LIMIT ".$start." , ".$limit;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$result = mysqli_query($link, $SQL ) or die("Couldn&#39;t execute query.".mysqli_error($link));</p>
<p class="MsoNormal"><span>&#160;</span></p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span lang="FR">$responce-&#62;page = $page;</span></p>
<p class="MsoNormal"><span lang="FR"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$responce-&#62;total = $total_pages;</span></p>
<p class="MsoNormal"><span lang="FR"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span>$responce-&#62;records = $count;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$i=0;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$responce-&#62;rows[$i][&#39;id&#39;]=$row[id];</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$responce-&#62;rows[$i][&#39;cell&#39;]=array($row[id],$row[name],$row[address], $row[phone],$row[fax],$row[email],$row[total]);</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>$i++;</p>
<p class="MsoNormal"><span>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span>} echo json-&#62;encode($responce);// coment if php 5 //echo</p>
<p class="MsoNormal">json_encode($responce); break; case 3:</p>
<p class="MsoNormal">}</p>
<p class="MsoNormal">mysqli_close($db);</p>
<p class="MsoNormal">&#160;</p>
<p class="MsoNormal">?&#62;</p>
]]></description>
        	        	<pubDate>Sat, 16 Jan 2010 07:57:56 +0200</pubDate>
        </item>
        <item>
        	<title>newperson on Ask: Integrated Search Toolbar-&#62;PHP-Mysql syntax</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13904</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13904</guid>
        	        	<description><![CDATA[<p><strong>$searchOn = Strip($_REQUEST[&#39;_search&#39;]);</strong></p>
<p>there is a function called Strip that will remove slashes from the user typed text</p>
</p>
<p>foreach( <strong>$sarr as $k=&#62;$v</strong>) {</p>
<p>more or less this is pretty much saying for every value that the user entered in *note that the $v is data that comes out of your Strip function which as I mentioned it removes slashes from the user typed fields.</p>
<p><strong>$wh .= &#8221; AND &#8220;.$k.&#8221; LIKE &#39;&#8221;.$v.&#8221;%&#39;&#8221;;</strong></p>
<p>If you noticed, your MYSQL syntax has .$wh at the end of it&#8230;.and it needs this for searching basically this constructs a where clause that gives appends AND id, invdate,name,note plus a LIKE statement and since id,invdate,name,note are integer,text fields you are able to use the LIKE operator as opposed to float values such as amount, tax,total that is why you don&#39;t see the LIKE operator in&#160;<strong>$wh .= &#8221; AND &#8220;.$k.&#8221; = &#8220;.$v;</strong></p>
<p>Hope this helps understand it a little better.</p>
<p>PS when I first picked up jqgrids I had no clue about php/js/html, I still don&#39;t know a whole lot about them but I can find my way much easier now and have come up with some really nice&#160;functioning grids.&#160;It took me a while to get going with it and understand some of these basic concepts, If it weren&#39;t for the demos I wouldn&#39;t have been able to figure it out. My suggestion to you is to spend some time on the demo section and also IRC helps a lot, there are MYSQL/PHP/JavaScript channels you can join to ask specific questions which will point you in the right direction, I suggest using the freenode irc servers.</p>
]]></description>
        	        	<pubDate>Thu, 14 Jan 2010 20:35:28 +0200</pubDate>
        </item>
        <item>
        	<title>Candra on Ask: Integrated Search Toolbar-&#62;PHP-Mysql syntax</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13897</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/ask-integrated-search-toolbar-php-mysql-syntax#p13897</guid>
        	        	<description><![CDATA[<p>Dear all,</p>
<p>I want to use integrated earch toolbar on my jggrid. I want to modificate your PHP-MYSQL&#160;code but i do not understand about this especially with the bold:</p>
<p>$wh = "";<br /><strong>$searchOn = Strip($_REQUEST[&#39;_search&#39;]);<br /></strong>if($searchOn==&#39;true&#39;) {<br /><strong> $sarr = Strip($_REQUEST);</strong><br /> foreach( <strong>$sarr as $k=&#62;$v</strong>) {<br /> switch ($k) {<br /> case &#39;id&#39;:<br /> case &#39;invdate&#39;:<br /> case &#39;name&#39;:<br /> case &#39;note&#39;:<br /><strong> $wh .= " AND ".$k." LIKE &#39;".$v."%&#39;";<br /></strong> break;<br /> case &#39;amount&#39;:<br /> case &#39;tax&#39;:<br /> case &#39;total&#39;:<br /><strong> $wh .= " AND ".$k." = ".$v;<br /></strong> break;<br /> }<br /> }<br />}</p>
</p>
<p>Could you help me to explain the logic of this syntax, please????</p>
<p>Thank for your help</p>
</p>
<p>Regards,</p>
</p>
<p>Candra</p>
]]></description>
        	        	<pubDate>Thu, 14 Jan 2010 14:37:53 +0200</pubDate>
        </item>
</channel>
</rss>