<?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: need help connecting with db</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db</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/need-help-connecting-with-db/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on need help connecting with db</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16680</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16680</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Sorry this is not jqGrid related, but PHP related issue.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Mon, 26 Apr 2010 13:32:12 +0300</pubDate>
        </item>
        <item>
        	<title>irteza on need help connecting with db</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16581</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16581</guid>
        	        	<description><![CDATA[<p>ok i tried opening controller.php and it says that there is an sql syntax error in line 1 . This is my controller.php file. I really couldnt figure out an error here.&#160;</p>
<p>&#60;?php</p>
<p>//include the information needed for the connection to MySQL data base server.</p>
<p>// we store here username, database and password</p>
<p>include("dbconfig.php");</p>
</p>
<p>// to the url parameter are added 4 parameters as described in colModel</p>
<p>// we should get these parameters to construct the needed query</p>
<p>// Since we specify in the options of the grid that we will use a GET method</p>
<p>// we should use the appropriate command to obtain the parameters.</p>
<p>// In our case this is $_GET. If we specify that we want to use post</p>
<p>// we should use $_POST. Maybe the better way is to use $_REQUEST, which</p>
<p>// contain both the GET and POST variables. For more information refer to php documentation.</p>
<p>// Get the requested page. By default grid sets this to 1.</p>
<p>$page = $_GET[&#39;page&#39;];</p>
</p>
<p>// get how many rows we want to have into the grid - rowNum parameter in the grid</p>
<p>$limit = $_GET[&#39;rows&#39;];</p>
</p>
<p>// get index row - i.e. user click to sort. At first time sortname parameter -</p>
<p>// after that the index from colModel</p>
<p>$sidx = $_GET[&#39;sidx&#39;];</p>
</p>
<p>// sorting order - at first time sortorder</p>
<p>$sord = $_GET[&#39;sord&#39;];</p>
</p>
<p>// if we not pass at first time index use the first column for the index or what you want</p>
<p>if(!$sidx) $sidx =1;</p>
</p>
<p>// connect to the MySQL database server</p>
<p>$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());</p>
</p>
<p>// select the database</p>
<p>mysql_select_db($database) or die("Error connecting to db.");</p>
</p>
<p>// calculate the number of rows for the query. We need this for paging the result</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM jos_chronoforms_ictjobrequest");</p>
<p>$row = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$count = $row[&#39;count&#39;];</p>
</p>
<p>// calculate the total pages for the query</p>
<p>if( $count &#62; 0 &#38;&#38; $limit &#62; 0) {</p>
<p>$total_pages = ceil($count/$limit);</p>
<p>} else {</p>
<p>$total_pages = 0;</p>
<p>}</p>
</p>
<p>// if for some reasons the requested page is greater than the total</p>
<p>// set the requested page to total page</p>
<p>if ($page &#62; $total_pages) $page=$total_pages;</p>
</p>
<p>// calculate the starting position of the rows</p>
<p>$start = $limit*$page - $limit;</p>
</p>
<p>// if for some reasons start position is negative set it to 0</p>
<p>// typical case is that the user type 0 for the requested page</p>
<p>if($start &#60;0) $start = 0;</p>
</p>
<p>// the actual query for the grid data</p>
<p>$SQL = "SELECT recordtime, ipaddress, ext_number, problem_description, problem_type, department, username FROM jos_chronoforms_ictjobrequest ORDER BY $sidx $sord LIMIT $start , $limit";</p>
<p>$result = mysql_query( $SQL ) or die("Couldn&#39;t execute query.".mysql_error());</p>
</p>
<p>// we should set the appropriate header information. Do not forget this.</p>
<p>header("Content-type: text/xml;charset=utf-8");</p>
</p>
<p>$s = "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?&#62;";</p>
<p>$s .=  "&#60;rows&#62;";</p>
<p>$s .= "&#60;page&#62;".$page."&#60;/page&#62;";</p>
<p>$s .= "&#60;total&#62;".$total_pages."&#60;/total&#62;";</p>
<p>$s .= "&#60;records&#62;".$count."&#60;/records&#62;";</p>
</p>
<p>// be sure to put text data in CDATA</p>
<p>while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>$s .= "&#60;row id=&#39;". $row[cf_id]."&#39;&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[record_time]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[ipaddress]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[ext_numebr]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;&#60;![CDATA[". $row[problem_description]."]]&#62;&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[problem_type]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[department]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;cell&#62;". $row[username]."&#60;/cell&#62;";</p>
<p>$s .= "&#60;/row&#62;";</p>
<p>}</p>
<p>$s .= "&#60;/rows&#62;";</p>
</p>
<p>echo $s;</p>
<p>?&#62;</p>
]]></description>
        	        	<pubDate>Wed, 21 Apr 2010 15:51:58 +0300</pubDate>
        </item>
        <item>
        	<title>irteza on need help connecting with db</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16578</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/need-help-connecting-with-db#p16578</guid>
        	        	<description><![CDATA[<p>Hi i am kinda new to all this. Wanted to implement jqgrid &#8230;. I followed the documentation on /jqgridwiki/doku.php?id=wiki:first_grid&#160;&#8230; I get the table but i cant get any information from the database</p>
<p>i have changed url:&#39;example.php&#39;, to url:&#39;controller.php&#39;,</p>
<p>In controller.php I have changed</p>
<p>$result = <a href="http://www.php.net/mysql_query" target="_blank">mysql_query("SELECT COUNT(*) AS count FROM invheader");</a>&#160;to the name of my table</p>
<p><a onclick="javascript:pageTracker._trackPageview(&#39;/outbound/article/http://www.php.net/mysql_query&#39;);" href="http://www.php.net/mysql_query" target="_blank"> </a>I have changed all instances of invheader to my table name and the fields accordingly</p>
<p>I have changed the fields in the main html file as well.</p>
<p>In dbconfig I have defined the username, password and database name using the same variables as required by controller.php.</p>
<p>I dont understand now what I am doing wrong. Can anyone please help me with this???? Thanks for your time.</p>
]]></description>
        	        	<pubDate>Wed, 21 Apr 2010 15:34:20 +0300</pubDate>
        </item>
</channel>
</rss>