<?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: No xml returned to grid.</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/no-xml-returned-to-grid</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/no-xml-returned-to-grid/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>marcfielding on No xml returned to grid.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/no-xml-returned-to-grid#p25800</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/no-xml-returned-to-grid#p25800</guid>
        	        	<description><![CDATA[<p>Hi guys,</p>
<p>Right i&#39;ve figured it all out now, heres the howto for newbies like me when following the wiki tutorial for Mysql and xml datasource.</p>
<p>1) Make sure if your using dreamweaver you dont keep any of the content that DW creates for you when &#160;you make a new file, remove all the existing HTML tags so all you have is the stuff between &#39;&#60;?php&#39; and &#39;?&#62;&#39;.</p>
<p>2) there is a typo in the wiki, sortname: &#39;id&#39;, SHOULD BE sortname: &#39;invid&#39;, when setting up the grid(the bit where you do jQuery("#list1").jqGrid({ blah blah</p>
</p>
<p>I know these were probably basic mistakes but hopefully it&#39;ll help someone.</p>
</p>
<p>Cheers</p>
</p>
<p>Marc</p></p>
]]></description>
        	        	<pubDate>Thu, 26 Jan 2012 00:21:10 +0200</pubDate>
        </item>
        <item>
        	<title>marcfielding on No xml returned to grid.</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/no-xml-returned-to-grid#p25798</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/no-xml-returned-to-grid#p25798</guid>
        	        	<description><![CDATA[<p>EDIT 3: Ok the problem was I was using the standard document that dreamweaver creates so I removed all the HTML tags and now if I do <a href="http://findajob.zapto.org/fb/griddata.php?page=1&#038;rows=50&#038;sidx=invid&#038;sord=ASC" rel="nofollow" target="_blank"><a href="http://findajob.zapto.org/fb/g" rel="nofollow">http://findajob.zapto.org/fb/g</a>.....8;sord=ASC</a></p>
<p>It actually outputs the correct xml ie:</p>
</p>
<div class="line">&#60;rows&#62;</div>
<div class="collapsible-content">
<div class="line">&#60;page&#62;1&#60;/page&#62;</div>
<div class="line">&#60;total&#62;13&#60;/total&#62;</div>
<div class="line">&#60;records&#62;645&#60;/records&#62;</div>
<div id="collapsible1" class="collapsible">
<div class="expanded">
<div class="line">&#60;row&#160;id="1"&#62;</div>
<div class="collapsible-content">
<div class="line">&#60;cell&#62;1&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;0000-00-00&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;0.00&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;0.00&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;0.00&#60;/cell&#62;</div>
<div id="collapsible2" class="collapsible">
<div class="expanded">
<div class="line">&#60;cell&#62;</div>
<div class="collapsible-content">
<div class="line">&#60;![CDATA[ note ]]&#62;</div>
</div>
<div class="line">&#60;/cell&#62;</div>
</div>
</div>
</div>
<div class="line">&#60;/row&#62;</div>
</div>
</div>
<div id="collapsible3" class="collapsible">
<div class="expanded">
<div class="line">&#60;row&#160;id="2"&#62;</div>
<div class="collapsible-content">
<div class="line">&#60;cell&#62;2&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;2010-01-01&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;103.98&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;45.34&#60;/cell&#62;</div>
<div class="line">&#60;cell&#62;149.32&#60;/cell&#62;</div>
<div id="collapsible4" class="collapsible">
<div class="expanded">
<div class="line">&#60;cell&#62;</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p>EDIT 2: If I manually pass params to my php script I get:</p>
<pre>This page contains the following errors:
<div>error on line 10 at column 6: XML declaration allowed only at the start of the document</div>
Below is a rendering of the page up to the first error.</pre>
<pre>Which is &#60;?php</pre>
<p>Hello,</p>
<p>I&#39;m new to jqgrid, jquery and PHP althought I do have a decent amount of development experience, I have the following code and it simply returns a blank grid(I dont get a record &#60;num&#62; out of &#60;num&#62; at the bottom right and the NAV bit doesnt appear. &#160;sorry for the long code listing but I&#39;ve noticed people generally dont include enough info so i&#39;m going all in&#8230;.</p>
<p>This is cut and pasted right out of the WIKI along with the data and the db structure so I cant figure out why its not working.&#160;</p>
</p>
<p>EDIT: I even got the griddata to output the xml to a textfile and it looks right to me.</p>
</p>
<p>Main page is below, griddata.php is at the bottom&#8230;</p>
<p>INDEX.PHP</p>
<p>&#60;!doctype html&#62;</p>
<p>&#60;html xmlns:fb="http://www.facebook.com/2008/fbml"&#62;</p>
<p>&#60;head&#62;</p>
<p>&#60;link href="style.css" rel="stylesheet" type="text/css"&#62;</p>
<p>&#60;title&#62;Facebook &#8211; FindaJob Test App&#60;/title&#62;</p>
<p>&#60;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js "&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript" src="jquery-1.7.1.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript" src="jquery.colorbox-min.js"&#62;&#60;/script&#62;</p>
<p>&#60;link type="text/css" href="jqueryui/css/smoothness/jquery-ui-1.8.17.custom.css" rel="Stylesheet" /&#62;</p>
<p>&#60;script type="text/javascript" src="jqueryui/js/jquery-ui-1.8.17.custom.min.js"&#62;&#60;/script&#62;</p>
<p>&#60;script type="text/javascript" src="menu/menu.js"&#62;&#60;/script&#62;</p>
<p>&#60;link type="text/css" href="menu/menu.css" rel="stylesheet" /&#62;</p>
<p>&#60;link rel="stylesheet" type="text/css" href="colorbox.css" /&#62;</p>
</p>
<p>&#60;link  rel="stylesheet" type="text/css" media="screen" href="jqgrid/css/ui.jqgrid.css" /&#62;</p>
<p>&#60;script src="jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script src="jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(document).bind(&#39;cbox_closed&#39;, function() {</p>
<p>window.location.href = &#39;newuser.php&#39;;</p>
<p>});</p>
<p>&#60;/script&#62;</p>
</p>
<p>&#60;?php</p>
<p>require &#39;facebook/src/facebook.php&#39;;</p>
<p>require_once &#39;auth.php&#39;;</p>
<p>include &#39;sqlfuncs.php&#39;;</p>
<p>include &#39;testgrid.php&#39;;</p>
<p>include &#39;userfuncs.php&#39;;</p>
</p>
<p>//session_start();</p>
<p>//3. requesting &#39;me&#39; to API</p>
<p>$me = null;</p>
<p>if ($session) {</p>
<p>try {</p>
<p>$uid = $facebook-&#62;getUser();</p>
<p>$me = $facebook-&#62;api(&#39;/me&#39;);</p>
<p>$newuser = uidisnew($uid);</p>
<p>$_SESSION[&#39;fb_session_key&#39;] = $session[&#39;session_key&#39;]; // store session key</p>
<p>} catch (FacebookApiException $e) {</p>
<p>error_log($e);</p>
<p>}</p>
<p>}</p>
<p>//4. login or logout</p>
<p>if ($me) {</p>
<p>$logoutUrl = $facebook-&#62;getLogoutUrl();</p>
<p>} else {</p>
<p>$loginUrl = $facebook-&#62;getLoginUrl();</p>
<p>}</p>
</p>
<p>if($newuser==0){</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>?&#62;</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(document).ready(function(){</p>
<p>$.colorbox({href:"login.html"});</p>
<p>});</p>
<p>&#60;/script&#62;</p>
<p>&#60;?php</p>
<p>}</p>
<p>?&#62;</p>
<p>&#60;/head&#62;</p>
<p>&#60;body&#62;</p>
<p>&#60;div id="menucont"&#62;</p>
<p>&#60;div id="menu"&#62;</p>
<p>&#60;ul class="menu"&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Logout&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Help&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;li class="last"&#62;&#60;a href="#"&#62;&#60;span&#62;Settings&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Search&#60;/span&#62;&#60;/a&#62;</p>
<p>&#60;/li&#62;</p>
<p>&#60;li&#62;&#60;a href="#" class="parent"&#62;&#60;span&#62;Home&#60;/span&#62;&#60;/a&#62;</p>
<p>&#60;div&#62;</p>
<p>&#60;ul&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Sub Item 1&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Sub Item 2&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;li&#62;&#60;a href="#"&#62;&#60;span&#62;Sub Item 3&#60;/span&#62;&#60;/a&#62;&#60;/li&#62;</p>
<p>&#60;/ul&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;/li&#62;</p>
<p>&#60;/ul&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;/div&#62;</p>
<p>&#60;table id="list1&#8243;&#62;&#60;tr &#62;&#60;td /&#62;&#60;/tr &#62;&#60;/table &#62;</p>
<p>&#60;div id="pager1&#8243;&#62;&#60;/div &#62;</p>
</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
<p>&#60;a href="http://apycom.com/"&#60;/a&#62;</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(document).ready(function(){</p>
<p>jQuery("#list1&#8243;).jqGrid({</p>
<p>url:&#39;griddata.php?q=1&#39;,</p>
<p>datatype: "xml",</p>
<p>colNames:[&#39;Inv No&#39;,&#39;Date&#39;, &#39;Client&#39;, &#39;Amount&#39;,&#39;Tax&#39;,&#39;Total&#39;,&#39;Notes&#39;],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,index:&#39;id&#39;, width:75},</p>
<p>{name:&#39;invdate&#39;,index:&#39;invdate&#39;, width:90},</p>
<p>{name:&#39;name&#39;,index:&#39;name&#39;, width:100},</p>
<p>{name:&#39;amount&#39;,index:&#39;amount&#39;, width:80, align:"right"},</p>
<p>{name:&#39;tax&#39;,index:&#39;tax&#39;, width:80, align:"right"},</p>
<p>{name:&#39;total&#39;,index:&#39;total&#39;, width:80,align:"right"},</p>
<p>{name:&#39;note&#39;,index:&#39;note&#39;, width:150, sortable:false}</p>
<p>],</p>
<p>rowNum:10,</p>
<p>autowidth: true,</p>
<p>rowList:[10,20,30],</p>
<p>pager: jQuery(&#39;#pager1&#39;),</p>
<p>sortname: &#39;id&#39;,</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>caption:"XML Example"</p>
<p>}).navGrid(&#39;#pager1&#39;,{edit:false,add:false,del:false});</p>
<p>});</p>
<p>&#60;/script&#62;</p>
</p>
<p><strong><span style="text-decoration: underline;">This is the griddata.php that should return the XML(griddata.php)</span></strong></p>
<p>&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;</p>
<p>&#60;html xmlns="http://www.w3.org/1999/xhtml"&#62;</p>
<p>&#60;head&#62;</p>
<p>&#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8&#8243; /&#62;</p>
<p>&#60;title&#62;Untitled Document&#60;/title&#62;</p>
<p>&#60;/head&#62;</p>
<p>&#60;body&#62;</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>ini_set("display_errors",1);</p>
<p>$dbuser=&#39;SOMEUSER&#39;;</p>
<p>$dbpassword=&#39;SOMEPASS&#39;;</p>
<p>$dbhost="localhost";</p>
<p>$database=&#39;SOMEDB&#39;;</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 &#8211; rowNum parameter in the grid</p>
<p>$limit = $_GET[&#39;rows&#39;];</p>
</p>
<p>// get index row &#8211; 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 &#8211; 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>// connect to the database</p>
<p>$db = mysql_connect($dbhost, $dbuser, $dbpassword)</p>
<p>or die("Connection Error: " . mysql_error());</p>
</p>
<p>mysql_select_db($database) or die("Error conecting to db.");</p>
<p>$result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id");</p>
<p>$row = mysql_fetch_array($result,MYSQL_ASSOC);</p>
<p>$count = $row[&#39;count&#39;];</p>
</p>
<p>if( $count &#62;0 ) {</p>
<p>$total_pages = ceil($count/$limit);</p>
<p>} else {</p>
<p>$total_pages = 0;</p>
<p>}</p>
<p>if ($page &#62; $total_pages) $page=$total_pages;</p>
<p>$start = $limit*$page &#8211; $limit; // do not put $limit*($page &#8211; 1)</p>
<p>$SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE "</p>
<p>." a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";</p>
<p>$result = mysql_query( $SQL ) or die("CouldnÂ’t execute query.".mysql_error());</p>
</p>
<p>if ( stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ) {</p>
<p>header("Content-type: application/xhtml+xml;charset=utf-8&#8243;); } else {</p>
<p>header("Content-type: text/xml;charset=utf-8&#8243;);</p>
<p>}</p>
<p>$et = "&#62;";</p>
</p>
<p>echo "&#60;?xml version=&#39;1.0&#39; encoding=&#39;utf-8&#39;?$etn";</p>
<p>echo "&#60;rows&#62;";</p>
<p>echo "&#60;page&#62;".$page."&#60;/page&#62;";</p>
<p>echo "&#60;total&#62;".$total_pages."&#60;/total&#62;";</p>
<p>echo "&#60;records&#62;".$count."&#60;/records&#62;";</p>
<p>// be sure to put text data in CDATA</p>
<p>while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {</p>
<p>echo "&#60;row id=&#39;". $row[id]."&#39;&#62;";</p>
<p>echo "&#60;cell&#62;". $row[id]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[invdate]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;&#60;![CDATA[". $row[name]."]]&#62;&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[amount]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[tax]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;". $row[total]."&#60;/cell&#62;";</p>
<p>echo "&#60;cell&#62;&#60;![CDATA[". $row[note]."]]&#62;&#60;/cell&#62;";</p>
<p>echo "&#60;/row&#62;";</p>
<p>}</p>
<p>echo "&#60;/rows&#62;";</p>
</p>
<p>?&#62;</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
]]></description>
        	        	<pubDate>Wed, 25 Jan 2012 22:38:40 +0200</pubDate>
        </item>
</channel>
</rss>