<?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: cannot save/update record</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/cannot-saveupdate-record</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/cannot-saveupdate-record/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>szervos on cannot save/update record</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cannot-saveupdate-record#p22952</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cannot-saveupdate-record#p22952</guid>
        	        	<description><![CDATA[<p>Hi experts,</p>
</p>
<p>I just start unsing jqGrid and I have a problem. I have a grid which is loading json data and my problem is that when i select add and submit the data nothing really happens.</p>
</p>
<p>I believe that I have not programmed correctly the edit_subsriber.php page. I really need your help because I am stacked for 2 days now.</p>
</p>
<p>Here is the page which displayes the grid:</p>
</p>
<blockquote>
<p>&#60;?php <br />include &#39;connect.php&#39;;</p>
<p>// create values for reporttypes<br />$rt_array = &#39;&#39;;</p>
<p>$sql_rt = "SELECT * FROM reporttype WHERE activated = &#39;1&#39; ORDER BY name ASC";<br />$res_rt = mysql_query($sql_rt) or die ("Cannot create report type array.");<br />while ($row = mysql_fetch_array($res_rt)){<br />&#160;&#160; &#160;$rt_array .= $row[&#39;reporttypeid&#39;].&#39;:&#39;.$row[&#39;name&#39;].&#39;;&#39;;<br />}<br />$rt_len = strlen($rt_array);<br />$rt_array = substr($rt_array,0,$rt_len-1);<br />?&#62;<br />&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&#62;<br />&#60;html xmlns="http://www.w3.org/1999/xhtml"&#62;<br />&#60;head&#62;<br />&#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&#62;<br />&#60;title&#62;CGM DataCS - Subscribers&#60;/title&#62;</p>
<p>&#60;link type="text/css" href="css/ui-lightness/jquery-ui-1.8.11.custom.css" rel="stylesheet" /&#62;&#160;&#160; &#160;<br />&#60;link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" /&#62;<br />&#160;<br />&#60;script src="js/jquery-1.5.2.min.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="js/i18n/grid.locale-en.js" type="text/javascript"&#62;&#60;/script&#62;<br />&#60;script src="js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;script&#62;<br />$(document).ready(function() {<br />jQuery("#list2").jqGrid({<br />&#160;&#160; &#160;url:&#39;data.php?q=subscriber&#39;,<br />&#160;&#160; &#160;datatype: "json",<br />&#160;&#160; &#160;colNames: [&#39;Subscriber ID&#39;,&#39;Name&#39;, &#39;Report Type&#39;, &#39;Active&#39;],<br />&#160;&#160; &#160;colModel: [<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;subscriberID&#39;,index:&#39;subscriberID&#39;, width:20, align:"center", editable:false},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;name&#39;,index:&#39;name&#39;, editable:true, edittype:&#39;text&#39;, editoptions:{size:60}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;rname&#39;,index:&#39;rname&#39;, width:20, align:&#39;center&#39;,editable:true, edittype:&#39;select&#39;, editoptions:{size:60, value:"&#60;?php echo $rt_array; ?&#62;"}&#160; }, <br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;rstatus&#39;,index:&#39;rstatus&#39;, width:20, align:&#39;center&#39;, formater:&#39;checkbox&#39;, editable:true, edittype:&#39;checkbox&#39;, editoptions:{value:"1:0"}}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160;&#160;&#160;&#160; ],<br />&#160;&#160; &#160;rowNum:25,<br />&#160;&#160; &#160;rowList:[25,50,100],<br />&#160;&#160; &#160;pager:&#39;#pager2&#39;,<br />&#160;&#160; &#160;sortname:&#39;subscriberID&#39;,<br />&#160;&#160; &#160;viewrecords: true,<br />&#160;&#160; &#160;sortorder: "desc",<br />&#160;&#160; &#160;caption: "Subscribers",<br />&#160;&#160; &#160;editurl: "edit_subscriber.php",<br />&#160;&#160; &#160;width:990,<br />&#160;&#160; &#160;height:450<br />&#160;&#160; &#160;<br />});</p>
<p>jQuery("#list2").jqGrid(&#39;navGrid&#39;,&#39;#pager2&#39;,{edit:true,&#160;&#160; &#160;add:true, del:false},<br />&#160;&#160; &#160;{<br />&#160;&#160; &#160;&#160;&#160; &#160;modal:true,<br />&#160;&#160; &#160;recreateForm: true,<br />&#160;&#160; &#160;editCaption: "Edit subscriber",<br />&#160;&#160; &#160;saveData: "Data has been changed! Save changes?",<br />&#160;&#160; &#160;bYes: "Yes",<br />&#160;&#160; &#160;bNo: "No",<br />&#160;&#160; &#160;bExit: "Cancel",<br />&#160;&#160; &#160;resize:false,<br />&#160;&#160; &#160;checkOnSubmit:true,<br />&#160;&#160; &#160;width: 400<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;},<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;{ <br />&#160;&#160; &#160;modal:true,<br />&#160;&#160; &#160;recreateForm: true,<br />&#160;&#160; &#160;addCaption: "Add subscriber",<br />&#160;&#160; &#160;saveData: "Data has been changed! Save changes?",<br />&#160;&#160; &#160;bYes: "Yes",<br />&#160;&#160; &#160;bNo: "No",<br />&#160;&#160; &#160;bExit: "Cancel",<br />&#160;&#160; &#160;resize:false,<br />&#160;&#160; &#160;checkOnSubmit:true,<br />&#160;&#160; &#160;width: 400<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;}<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;);<br />&#160;&#160; &#160;<br />});<br />&#60;/script&#62;<br />&#60;/head&#62;<br />&#60;body&#62;</p>
<p>&#60;table id="list2"&#62;&#60;/table&#62;<br />&#60;div id="pager2"&#62;&#60;/div&#62;</p>
<p>&#60;/body&#62;<br />&#60;/html&#62;</p>
</blockquote>
<p>And this is what I have enter in edit_subscriber.php which should insert the new record in the database:</p>
<blockquote>
<p>&#60;?php</p>
<p>$name = $_POST[&#39;name&#39;];<br />$reporttypeid = $_POST[&#39;rname&#39;];<br />$activated = &#39;&#39;;</p>
<p>$sql = "INSERT INTO subscriber (name,reporttypeid,activated) VALUES (&#39;$name,&#39;$reporttypeid&#39;,&#39;$activated&#39;) ";</p>
<p>$result = mysql_query($sql) or die ("SQL error: " . mysql_error());</p>
<p>?&#62;</p>
</blockquote>
]]></description>
        	        	<pubDate>Wed, 27 Apr 2011 18:07:56 +0300</pubDate>
        </item>
</channel>
</rss>