<?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: Search is not responding as expected</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected</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/search-is-not-responding-as-expected/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>gexhi on Search is not responding as expected</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23856</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23856</guid>
        	        	<description><![CDATA[<p>hello,</p>
<p>I found a solution thanks to :<a href="http://blog.brzezinka.eu/webmaster-tips/jquery/how-to-enable-the-search-functionality-in-jqgrid/comment-page-1#comment-511" rel="nofollow" target="_blank"><a href="http://blog.brzezinka.eu/webma" rel="nofollow">http://blog.brzezinka.eu/webma</a>.....omment-511</a></p>
</p>
<p>in my case for all those who want to use mssql this is the php:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1038' value='Select Code' data-codeid='sfcode1038' /></p>
<div class='sfcode' id='sfcode1038'>&#60;?php<br />//defined(&#39;_JEXEC&#39;,1) or die(&#39;Restricted access&#39;);<br />//defined( &#39;_VALID_MOS&#39; ) or die( &#39;Restricted access&#39; );</p>
<p>//$host&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;host&#39; ) );<br />//$database&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;database&#39; ) );<br />//$user&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;user&#39; ) );<br />//$password&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;password&#39; ) );</p>
<p>//array to translate the search type<br />$ops = array(<br />&#160;&#160;&#160; &#39;eq&#39;=&#62;&#39;=&#39;, //equal<br />&#160;&#160;&#160; &#39;ne&#39;=&#62;&#39;&#60;&#62;&#39;,//not equal<br />&#160;&#160;&#160; &#39;lt&#39;=&#62;&#39;&#60;&#39;, //less than<br />&#160;&#160;&#160; &#39;le&#39;=&#62;&#39;&#60;=&#39;,//less than or equal<br />&#160;&#160;&#160; &#39;gt&#39;=&#62;&#39;&#62;&#39;, //greater than<br />&#160;&#160;&#160; &#39;ge&#39;=&#62;&#39;&#62;=&#39;,//greater than or equal<br />&#160;&#160;&#160; &#39;bw&#39;=&#62;&#39;LIKE&#39;, //begins with<br />&#160;&#160;&#160; &#39;bn&#39;=&#62;&#39;NOT LIKE&#39;, //doesn&#39;t begin with<br />&#160;&#160;&#160; &#39;in&#39;=&#62;&#39;LIKE&#39;, //is in<br />&#160;&#160;&#160; &#39;ni&#39;=&#62;&#39;NOT LIKE&#39;, //is not in<br />&#160;&#160;&#160; &#39;ew&#39;=&#62;&#39;LIKE&#39;, //ends with<br />&#160;&#160;&#160; &#39;en&#39;=&#62;&#39;NOT LIKE&#39;, //doesn&#39;t end with<br />&#160;&#160;&#160; &#39;cn&#39;=&#62;&#39;LIKE&#39;, // contains<br />&#160;&#160;&#160; &#39;nc&#39;=&#62;&#39;NOT LIKE&#39;&#160; //doesn&#39;t contain<br />);<br />function getWhereClause($col, $oper, $val){<br />&#160;&#160;&#160; global $ops;<br />&#160;&#160;&#160; if($oper == &#39;bw&#39; &#124;&#124; $oper == &#39;bn&#39;) $val .= &#39;%&#39;;<br />&#160;&#160;&#160; if($oper == &#39;ew&#39; &#124;&#124; $oper == &#39;en&#39; ) $val = &#39;%&#39;.$val;<br />&#160;&#160;&#160; if($oper == &#39;cn&#39; &#124;&#124; $oper == &#39;nc&#39; &#124;&#124; $oper == &#39;in&#39; &#124;&#124; $oper == &#39;ni&#39;) $val = &#39;%&#39;.$val.&#39;%&#39;;<br />&#160;&#160;&#160; return &#34; WHERE $col {$ops[$oper]} &#39;$val&#39; &#34;;<br />}<br />$where = &#34;&#34;; //if there is no search request sent by jqgrid, $where should be empty<br />$searchField = isset($_GET[&#39;searchField&#39;]) ? $_GET[&#39;searchField&#39;] : false;<br />$searchOper = isset($_GET[&#39;searchOper&#39;]) ? $_GET[&#39;searchOper&#39;]: false;<br />$searchString = isset($_GET[&#39;searchString&#39;]) ? $_GET[&#39;searchString&#39;] : false;<br />if ($_GET[&#39;_search&#39;] == &#39;true&#39;) {<br />&#160;&#160;&#160; $where = getWhereClause($searchField,$searchOper,$searchString);<br />}<br />//$host&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;host&#39; ) );<br />//$database&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;database&#39; ) );<br />//$user&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;user&#39; ) );<br />//$password&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;password&#39; ) );<br />//connection to the database<br />$host&#160;&#160;&#160;&#160; = &#39;xxxxxxx&#39;;<br />$user&#160;&#160;&#160;&#160; = &#39;xxxxxxx&#39;;<br />$password = &#39;xxxxxxx&#39;;<br />$database = &#39;xxxxxxx&#39;;</p>
<p>$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</p>
<p>if(!$sidx) $sidx =1;</p>
<p>//connect to the database<br />$db = mssql_connect($host, $user, $password) or die(&#34;Connection Error: &#34; . mssql_error());<br />mssql_select_db($database) or die(&#34;Error conecting to db.&#34;);</p>
<p>$result = mssql_query(&#34;SELECT COUNT(*) AS count FROM [Joomla].[dbo].[DEBITOR_TE_SHKEPUTUR]&#34;);<br />$row = mssql_fetch_array($result,MSSQL_ASSOC);<br />$count = $row[&#39;count&#39;];<br />$plus1=&#39;1&#39;;</p>
<p>if( $count &#62;0 ) {<br />&#160;&#160;&#160; $totalpages = ceil($count/$limit);<br />&#160;&#160;&#160; } else {<br />&#160;&#160;&#160; $totalpages = 0;<br />&#160;&#160;&#160; }</p>
<p>if ($page &#62; $totalpages) $page=$totalpages;<br />$start = ($limit*$page - $limit);<br />$start1=$start+$plus1;<br />$next=$start+$limit; // do not put $limit*($page - 1)<br />$SQL = &#34;SELECT * FROM (SELECT row_number() OVER (ORDER BY &#34;.$sidx.&#34;&#160;&#160; &#34;.$sord.&#34;) AS rownum ,ID,[EMER_DEBITORI],[NR_CONT] ,[Joomla_Date_Shkeputje],[DEBIA_TOTALE],[TIP_DESC],[EMER_ZONE] <br />FROM [Joomla].[dbo].[DEBITOR_TE_SHKEPUTUR] &#34;.$where.&#34;) AS A<br />WHERE A.rownum BETWEEN &#34;.$start1.&#34; and &#34;.$next;<br />$result = mssql_query( $SQL ) or die(&#34;Couldn t execute query.&#34;.mssql_error());</p>
<p>if ( stristr($_SERVER[&#34;HTTP_ACCEPT&#34;],&#34;application/xhtml+xml&#34;) ) {<br />&#160;&#160;&#160; header(&#34;Content-type: application/xhtml+xml;charset=utf-8&#34;);<br />&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; header(&#34;Content-type: text/xml;charset=utf-8&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160; &#160;<br />&#160;&#160;&#160; $et = &#34;&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?$etn&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;rows&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;page&#62;&#34;.$page.&#34;&#60;/page&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;total&#62;&#34;.$totalpages.&#34;&#60;/total&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;records&#62;&#34;.$count.&#34;&#60;/records&#62;&#34;;</p>
<p>&#160;&#160;&#160; // be sure to put text data in CDATA<br />&#160;&#160;&#160; while($row = mssql_fetch_array($result,MSSQL_ASSOC)) {<br />&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;row id=&#39;&#34;. $row[ID].&#34;&#39;&#62;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;cell&#62;&#34;. $row[ID].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[EMER_DEBITORI].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[NR_CONT].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //echo &#34;&#60;cell&#62;&#34;. $row[name].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160; echo &#34;&#60;cell&#62;&#60;![CDATA[&#34;. $row[Joomla_Date_Shkeputje].&#34;]]&#62;&#60;/cell&#62;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;cell&#62;&#34;. $row[Joomla_Date_Shkeputje].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[DEBIA_TOTALE].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[TIP_DESC].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[EMER_ZONE].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160; //&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[note].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; echo &#34;&#60;cell&#62;&#60;![CDATA[&#34;. $row[note].&#34;]]&#62;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;/row&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;}<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160; echo &#34;&#60;/rows&#62;&#34;;</p>
<p>&#160;&#160;&#160; mssql_close($db)</p>
<p>?&#62;</p>
</div>
<p>Thank you Tony for your direction.</p>
]]></description>
        	        	<pubDate>Mon, 04 Jul 2011 13:45:58 +0300</pubDate>
        </item>
        <item>
        	<title>gexhi on Search is not responding as expected</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23854</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23854</guid>
        	        	<description><![CDATA[<blockquote>
<p>tony said:</p>
<p>Hello,</p>
<p>Please check your php code.</p>
<p>You do not have any logic for serach.</p>
<p>Serch does not work if there is no logic in your server side code.</p>
<p>Please post only problems related with the grid and not with PHP.</p>
<p>Regards</p>
</blockquote>
<hr />
<p>Thank you Tony for your quick response,</p>
<p>I have seen jqGrid Demos, and I can&#39;t find the resolution for the search logic in my php, could you/everyone please help me on this? <br />Appreciate your help</p>
]]></description>
        	        	<pubDate>Mon, 04 Jul 2011 12:20:51 +0300</pubDate>
        </item>
        <item>
        	<title>tony on Search is not responding as expected</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23853</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23853</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Please check your php code.</p>
<p>You do not have any logic for serach.</p>
<p>Serch does not work if there is no logic in your server side code.</p>
<p>Please post only problems related with the grid and not with PHP.</p>
<p>Regards</p>
]]></description>
        	        	<pubDate>Mon, 04 Jul 2011 12:01:02 +0300</pubDate>
        </item>
        <item>
        	<title>gexhi on Search is not responding as expected</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23850</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/search-is-not-responding-as-expected#p23850</guid>
        	        	<description><![CDATA[<p>Hi</p>
<p>I am having a problem with the search feature, with single field and multiple fields. Always is showing all table records when i click to find a single ID or a name or a date.</p>
<p>this is my code:</p>
<p>Java Script:</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7727' value='Select Code' data-codeid='sfcode7727' /></p>
<div class='sfcode' id='sfcode7727'>&#60;?php // no direct access<br />defined( &#39;_JEXEC&#39; ) or die( &#39;Restricted access&#39; );?&#62;<br />&#60;?php<br />&#160;&#160;&#160; $myfirstgridpath=JURI::root().&#39;modules/mod_Nderprerje/&#39;;<br />&#160;&#160; &#160;<br />&#160;&#160;&#160; $document =&#38; JFactory::getDocument();<br />&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160; $document-&#62;addStyleSheet($myfirstgridpath.&#39;css/ui-lightness/jquery-ui-1.7.2.custom.css&#39;);<br />&#160;&#160;&#160; $document-&#62;addStyleSheet($myfirstgridpath.&#39;css/ui.jqgrid.css&#39;);<br />&#160;&#160; &#160; &#160;<br />&#160;&#160;&#160; $document-&#62;addScript($myfirstgridpath.&#39;js/jquery-1.4.2.min.js&#39;);<br />&#160;&#160;&#160; $document-&#62;addScript($myfirstgridpath.&#39;js/i18n/grid.locale-en.js&#39;);<br />&#160;&#160;&#160; $document-&#62;addScript($myfirstgridpath.&#39;js/jquery.jqGrid.min.js&#39;);</p>
<p>?&#62;</p>
<p>&#60;script type=&#34;text/javascript&#34;&#62;<br />&#160;&#160;&#160; jQuery.noConflict();</p>
<p>&#160;&#160;&#160; jQuery(document).ready(function(){<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery(&#34;#list&#34;).jqGrid({<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; url:&#39;&#60;?php echo $myfirstgridpath.&#39;/datasource.php&#39;;?&#62;&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; datatype: &#34;xml&#34;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; mtype:&#39;GET&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colNames:[&#39;ID&#39;,&#39;Emri&#39;,&#39;Kontrata&#39;, &#39;Data&#39;, &#39;Debia&#39;,&#39;Tipi&#39;,&#39;Zona&#39;],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; colModel:[{name:&#39;ID&#39;,index:&#39;ID&#39;, width:50},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;EMER_DEBITORI&#39;,index:&#39;EMER_DEBITORI&#39;, width:100},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;NR_CONT&#39;,index:&#39;NR_CONT&#39;, width:60},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;Joomla_Date_Shkeputje&#39;,index:&#39;Joomla_Date_Shkeputje&#39;, width:110},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;DEBIA_TOTALE&#39;,index:&#39;DEBIA_TOTALE&#39;, width:80, align:&#34;right&#34;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;TIP_DESC&#39;,index:&#39;TIP_DESC&#39;, width:70, align:&#34;right&#34;},<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {name:&#39;EMER_ZONE&#39;,index:&#39;EMER_ZONE&#39;, width:80,align:&#34;right&#34;}],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowNum:10,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; loadonce:false,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; autowidth:true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; rowList:[10,20,30,100],<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; pager: jQuery(&#39;#pager&#39;),<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortname: &#39;ID&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; viewrecords: true,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; sortorder: &#34;ASC&#34;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; caption:&#34;Lista e Debitoreve te nderprere&#34;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; loadtext:&#34;Ne kerkim, ju lutem prisni&#34;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160; toolbar:[true,&#34;top&#34;]<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; });</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; jQuery(&#34;#list&#34;).jqGrid(&#39;navGrid&#39;,&#39;#pager&#39;,{edit:false,add:false,del:false});</p>
<p>&#160;&#160; &#160;&#160;&#160; &#160;&#160; });</p>
<p>&#60;/script&#62;</p>
<p>&#60;table id=&#34;list&#34; class=&#34;search&#34;&#62;&#60;/table&#62;<br />&#60;div id=&#34;pager&#34; class=&#34;search&#34; style=&#34;text-align:center;&#34;&#62;&#60;/div&#62;</p>
</div>
<p>&#160; <br />&#160;&#160;&#160; and this is php:</p>
<p>&#160;&#160; &#160;</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1847' value='Select Code' data-codeid='sfcode1847' /></p>
<div class='sfcode' id='sfcode1847'>&#160;<br />&#60;?php<br />//defined(&#39;_JEXEC&#39;,1) or die(&#39;Restricted access&#39;);<br />//defined( &#39;_VALID_MOS&#39; ) or die( &#39;Restricted access&#39; );</p>
<p>//$host&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;host&#39; ) );<br />//$database&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;database&#39; ) );<br />//$user&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;user&#39; ) );<br />//$password&#160;&#160; &#160;&#160;&#160; &#160;= trim( $params-&#62;get( &#39;password&#39; ) );</p>
<p>$host&#160;&#160;&#160;&#160; = &#39;dbhost&#39;;<br />$user&#160;&#160;&#160;&#160; = &#39;xxxxxx&#39;;<br />$password = &#39;xxxxxxxx&#39;;<br />$database = &#39;xxxxxx&#39;;</p>
<p>$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</p>
<p>if(!$sidx) $sidx =1;</p>
<p>//connect to the database<br />$db = mssql_connect($host, $user, $password) or die(&#34;Connection Error: &#34; . mssql_error());<br />mssql_select_db($database) or die(&#34;Error conecting to db.&#34;);</p>
<p>$result = mssql_query(&#34;SELECT COUNT(*) AS count FROM [Joomla].[dbo].[DEBITOR_TE_SHKEPUTUR]&#34;);<br />$row = mssql_fetch_array($result,MSSQL_ASSOC);<br />$count = $row[&#39;count&#39;];<br />$plus1=&#39;1&#39;;</p>
<p>if( $count &#62;0 ) {<br />&#160;&#160;&#160; $totalpages = ceil($count/$limit);<br />&#160;&#160;&#160; } else {<br />&#160;&#160;&#160; $totalpages = 0;<br />&#160;&#160;&#160; }</p>
<p>if ($page &#62; $totalpages) $page=$totalpages;<br />$start = ($limit*$page - $limit);<br />$start1=$start+$plus1;<br />$next=$start+$limit; // do not put $limit*($page - 1)<br />$SQL = &#34;SELECT * FROM (SELECT row_number() OVER (ORDER BY &#34;.$sidx.&#34;&#160;&#160; &#34;.$sord.&#34;) AS rownum ,ID,[EMER_DEBITORI],[NR_CONT] ,[Joomla_Date_Shkeputje],[DEBIA_TOTALE],[TIP_DESC],[EMER_ZONE] FROM [Joomla].[dbo].[DEBITOR_TE_SHKEPUTUR]) AS A<br />WHERE A.rownum BETWEEN &#34;.$start1.&#34; and &#34;.$next;<br />$result = mssql_query( $SQL ) or die(&#34;Couldn t execute query.&#34;.mssql_error());</p>
<p>if ( stristr($_SERVER[&#34;HTTP_ACCEPT&#34;],&#34;application/xhtml+xml&#34;) ) {<br />&#160;&#160;&#160; header(&#34;Content-type: application/xhtml+xml;charset=utf-8&#34;);<br />&#160;&#160;&#160; } else {<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; header(&#34;Content-type: text/xml;charset=utf-8&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160; &#160;<br />&#160;&#160;&#160; $et = &#34;&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?$et\n&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;rows&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;page&#62;&#34;.$page.&#34;&#60;/page&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;total&#62;&#34;.$totalpages.&#34;&#60;/total&#62;&#34;;<br />&#160;&#160;&#160; echo &#34;&#60;records&#62;&#34;.$count.&#34;&#60;/records&#62;&#34;;</p>
<p>&#160;&#160;&#160; // be sure to put text data in CDATA<br />&#160;&#160;&#160; while($row = mssql_fetch_array($result,MSSQL_ASSOC)) {<br />&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;row id=&#39;&#34;. $row[ID].&#34;&#39;&#62;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;cell&#62;&#34;. $row[ID].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[EMER_DEBITORI].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[NR_CONT].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; //echo &#34;&#60;cell&#62;&#34;. $row[name].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; //&#160; echo &#34;&#60;cell&#62;&#60;![CDATA[&#34;. $row[Joomla_Date_Shkeputje].&#34;]]&#62;&#60;/cell&#62;&#34;;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;echo &#34;&#60;cell&#62;&#34;. $row[Joomla_Date_Shkeputje].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[DEBIA_TOTALE].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[TIP_DESC].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[EMER_ZONE].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160; //&#160;&#160;&#160;&#160; echo &#34;&#60;cell&#62;&#34;. $row[note].&#34;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160; //&#160;&#160; echo &#34;&#60;cell&#62;&#60;![CDATA[&#34;. $row[note].&#34;]]&#62;&#60;/cell&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; echo &#34;&#60;/row&#62;&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;}<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160; echo &#34;&#60;/rows&#62;&#34;;</p>
<p>&#160;&#160;&#160; mssql_close($db)</p>
<p>?&#62;</p>
</div>
<p>As you can see I am using a SQL server database for my data.</p>
<p>Any help will be grate,<img class="spSmiley" style="margin:0" title="Embarassed" src="/blog/wp-content/forum-smileys/sf-embarassed.gif" alt="Embarassed" /></p></p>
]]></description>
        	        	<pubDate>Mon, 04 Jul 2011 11:26:56 +0300</pubDate>
        </item>
</channel>
</rss>