<?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: How to save  data in database?</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database</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/how-to-save-data-in-database/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>ananthvk on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p27233</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p27233</guid>
        	        	<description><![CDATA[<p>A small change: you have to change the $_POST(oper) to &#160;$_POST(&#39;oper&#39;)&#160;</p>
<p>without quotes you would get parse error 200.</p>
]]></description>
        	        	<pubDate>Thu, 30 Aug 2012 20:26:15 +0300</pubDate>
        </item>
        <item>
        	<title>finedesignz on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p7007</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p7007</guid>
        	        	<description><![CDATA[</p>
<p>I just got mine to work&#8230; had a few minor errors (still a newbie with PHP).&#160; The grid is awesome, works great.</p>
<p><strong>I&#39;m not sure how familiar you are with PHP, so here&#39;s my basic instructions:</strong></p>
<p>To send your data to someurl.php, add the parameter to your colModel properties:</p>
<p><span class="sfcode">editurl: "someurl.php",</span></p>
<p>or use the navigator, which is what I did:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit5083' value='Select Code' data-codeid='sfcode5083' /></p>
<div class='sfcode' id='sfcode5083'>.navGrid(&#39;#pager&#39;,<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {add: true, edit: true, del: true, search: true}, //options<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {height:200,width:600,reloadAfterSubmit:false,url:&#39;someurl.php&#39;}, // edit options<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {height:200,width:600,reloadAfterSubmit:false,url:&#39;someurl.php&#39;}, // add options<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {reloadAfterSubmit:false,url:&#39;someurl.php&#39;}, // del options<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {width:600} // search options<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; );</div>
</p>
<p>I would recommend downloading Firebug (<a href="http://getfirebug.com/" rel="nofollow" target="_blank">http://getfirebug.com/</a>) for Firefox.&#160; It will show you what is being sent to the someurl.php page by jqgrid.&#160; For example, Firebug shows me this after expanding the POST url:</p>
<table border="0">
<tbody>
<tr>
<td><strong>app</strong></td>
<td>11</td>
</tr>
<tr>
<td><strong>expiration</strong></td>
<td>06-01-10</td>
</tr>
<tr>
<td><strong>id</strong></td>
<td>_empty</td>
</tr>
<tr>
<td><strong>oper</strong></td>
<td>add</td>
</tr>
<tr>
<td><strong>user_id</strong></td>
<td>14</td>
</tr>
</tbody>
</table>
<p>All of this is a simple form submission sent via POST. Once you can see the data you are processing, then you create your someurl.php, using this better basic example than the one above:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit7967' value='Select Code' data-codeid='sfcode7967' /></p>
<div class='sfcode' id='sfcode7967'>
<p>&#60;?php</p>
<p>// Get information from entry<br />&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];&#160; //id field from POST above<br />&#160;&#160;&#160; $exp = $_POST[&#39;expiration&#39;]; //expiration field from POST above<br />&#160;&#160;&#160; $app_id = $_POST[&#39;app&#39;];&#160; //app field from POST above<br />&#160;&#160;&#160; $user_id = $_POST[&#39;user_id&#39;];&#160; //user_id field from POST above</p>
<p>// connect to the MySQL database server<br />include &#39;includes/dbconfig.inc.php&#39;;<br />$con = mysql_connect($dbhost, $dbuser, $dbpassword);<br />if (!$con)<br />&#160; {<br />&#160; die(&#39;Could not connect: &#39; . mysql_error());<br />&#160; }<br />@mysql_select_db($database,$con) or die(&#8221;Error connecting to db.&#8221;);</p>
</div>
<p>Then set your MySQL database commands to a php variable:</p>
<p><input type='button' class='sfcodeselect' name='sfselectit3813' value='Select Code' data-codeid='sfcode3813' /></p>
<div class='sfcode' id='sfcode3813'>&#160;$add = &#8220;INSERT INTO table_name (user_id,app_id,expiration) VALUES (&#39;&#8221; . $user_id . &#8220;&#39;,&#39;&#8221; . $app_id . &#8220;&#39;,&#39;&#8221; . $exp . &#8220;&#39;)&#8221;;</p>
<p>&#160;&#160;&#160; $upd = &#8220;UPDATE `table_name` SET app_id = &#39;&#8221; . $app_id . &#8220;&#39;, user_id = &#39;&#8221; . $user_id . &#8220;&#39;, expiration = &#39;&#8221; . $exp . &#8220;&#39; WHERE user_id=&#39;&#8221; . $id . &#8220;&#39;&#8221;;</p>
<p>&#160;&#160;&#160; $del = &#8220;DELETE FROM table_name WHERE id=&#39;&#8221; . $id . &#8220;&#39;&#8221;;</p>
</div>
<p>Finally, use php IF() to determine if you are adding, editing, or deleting a record based on the &#8220;operator&#8221; sent from above.&#160; I like this set up because when you try to add, edit, or delete a record, it will return &#8220;License added&#8221;, etc. in Firebug so you know if it&#39;s working.</p>
<p><input type='button' class='sfcodeselect' name='sfselectit1543' value='Select Code' data-codeid='sfcode1543' /></p>
<div class='sfcode' id='sfcode1543'>// ADDS NEW APP RECORD<br />if($_REQUEST[oper]==&#39;add&#39;) {<br />&#160;&#160;&#160; if (mysql_query($add,$con))<br />&#160; {<br />&#160; echo &#8220;License added.&#8221;;<br />&#160; }<br />else<br />&#160; {<br />&#160; echo &#8220;Error adding user: &#8221; . mysql_error();<br />&#160; }</p>
<p>// MODIFIES USER RECORD<br />} elseif($_REQUEST[oper]==&#39;edit&#39;) {</p>
<p>&#160;&#160; if (mysql_query($upd,$con))<br />&#160; {<br />&#160; echo &#8220;User edited.&#8221;;<br />&#160; }<br />else<br />&#160; {<br />&#160; echo &#8220;Error editing user: &#8221; . mysql_error();<br />&#160; }</p>
<p>// DELETES USER RECORD AND ASSOCIATED ACCESS RELATIONSHIPS<br />} elseif($_POST[oper]==&#39;del&#39;) {<br />&#160;&#160; if (mysql_query($del,$con))<br />&#160; {<br />&#160; echo &#8220;User deleted.&#8221;;<br />&#160; }<br />else<br />&#160; {<br />&#160; echo &#8220;Error deleting user: &#8221; . mysql_error();<br />&#160; }</p>
<p>&#160;}<br />&#160;mysql_close($con);</p>
<p>?&#62;</p>
</div>
<p>I&#39;m sure some PHP pro&#39;s out there could explain it a lot better, and someone may add corrections to this post, but this is working for me.&#160; I have 3 grids, including one subgrid, and struggled for quite a while to figure this out.&#160; Hopefully this will help you.</p>
<p>JqGrid is definitely awesome!</p>
]]></description>
        	        	<pubDate>Mon, 01 Jun 2009 13:01:45 +0300</pubDate>
        </item>
        <item>
        	<title>JiMKE on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6993</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6993</guid>
        	        	<description><![CDATA[<p>Hello, <strong>finedesignz.</strong></p>
<p>Your PHP example is so simple. I understand how it works.</p>
<p>But how you send data in your someurl.php ?</p>
]]></description>
        	        	<pubDate>Sun, 31 May 2009 12:59:03 +0300</pubDate>
        </item>
        <item>
        	<title>prbabu on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6971</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6971</guid>
        	        	<description><![CDATA[<p>I would suggest read the documentation. Infact, most of the examples are in PHP-MySQL.</p>
<p>&#160; It takes few days to get your head around and once you have done that "little" work, you could post like me on this forum!</p>
<p>-Praveen</p></p>
]]></description>
        	        	<pubDate>Fri, 29 May 2009 21:14:31 +0300</pubDate>
        </item>
        <item>
        	<title>finedesignz on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6967</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6967</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>What a great plugin!&#160; I am also having trouble getting the edited data to the server.&#160; Here&#39;s what I found, although I&#39;m still having trouble getting it to work.</p>
</p>
<p>But since I have found almost no help on this after searching the web for hours, I thought I&#39;d try to help...</p>
<p>I believe this should be the contents of &#39;someurl.php&#39; (the example demo file has a blank one)</p>
<p><input type='button' class='sfcodeselect' name='sfselectit9812' value='Select Code' data-codeid='sfcode9812' /></p>
<div class='sfcode' id='sfcode9812'>
<p>&#60;?</p>
<p>// FETCHES THE &#39;USERS&#39; TABLE DATA<br />&#160;if($_GET[oper]==&#39;sel&#39;){</p>
<p>// connect to the MySQL database server<br />include &#39;includes/auth.inc.php&#39;;</p>
<p>// ADDS NEW APP RECORD - I have 5 columns, and these are the titles</p>
<p>} elseif($_POST[oper]==&#39;add&#39;) {</p>
<p>&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];<br />&#160;&#160;&#160; $ins = &#8220;INSERT INTO appid (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note)&#8221;;<br />&#160;&#160;&#160; @mysql_query($ins) or die(&#8221;failed&#8221;);</p>
<p>// MODIFIES USER RECORD<br />} elseif($_POST[oper]==&#39;edit&#39;) {</p>
<p>&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];<br />&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];</p>
<p>&#160;&#160;&#160; $upd = &#8220;UPDATE appid SET (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note) WHERE id=$id&#8221;;<br />&#160;&#160;&#160; @mysql_query($upd) or die(&#8221;failed&#8221;);</p>
<p>// DELETES USER RECORD AND ASSOCIATED ACCESS RELATIONSHIPS<br />} elseif($_POST[oper]==&#39;del&#39;) {</p>
<p>&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];</p>
<p>&#160;&#160;&#160; $SQL = &#8220;DELETE FROM appid WHERE id=$id&#8221;;<br />&#160;&#160;&#160; $res = @mysql_query($SQL) or die(&#8221;failed&#8221;);<br />&#160;}<br />&#160;mysql_close($con);</p>
<p>?&#62;</p>
</div>
<p>However, again, I have been unable to actually get this to work.&#160; I am hoping someone on this forum will give us more help?</p>
<p>Thanks in advance.</p>
]]></description>
        	        	<pubDate>Fri, 29 May 2009 18:18:25 +0300</pubDate>
        </item>
        <item>
        	<title>JiMKE on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6965</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6965</guid>
        	        	<description><![CDATA[<p>Thanx, xuding.</p>
<p>This example with cakePHP so helpful for me.</p>
<p>But my server side wrote on pure PHP.</p>
<p>May be somebody can show example with pure PHP?</p>
<p>Deadline of my project is coming=)</p>
<p>Thanx.</p></p>
]]></description>
        	        	<pubDate>Fri, 29 May 2009 10:54:56 +0300</pubDate>
        </item>
        <item>
        	<title>xuding on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6961</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6961</guid>
        	        	<description><![CDATA[<p>Dude,</p>
<p>you need some server side language to handle that.</p>
<p>this is a simple working copy of jqgrid+cakephp(server side language PHP)</p>
<p><a href="http://Dude,  you need some server side language to handle that.  this is a simple working copy of jqgrid+cakephp(server side language PHP)   http//www.the-di-lab.com/?p=28  Try to look at the function indexedit() in Cakephp+JqGrid\\demo\\app\\controllers\\apples_controller.  This is where it does edit,delete,and add.  Hope you can get the basic idea from here.   regards  The-Di-Lab" target="_blank">http://www.the-di-lab.com/?p=28</a></p>
<p>Try to look at the function indexedit() in Cakephp+JqGrid\\demo\\app\\controllers\\apples_controller.</p>
<p>This is where it does edit,delete,and add.</p>
<p>Hope you can get the basic idea from here.</p>
<p>regards</p>
<p>The-Di-Lab</p>
]]></description>
        	        	<pubDate>Thu, 28 May 2009 22:33:13 +0300</pubDate>
        </item>
        <item>
        	<title>JiMKE on How to save  data in database?</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6956</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/how-to-save-data-in-database#p6956</guid>
        	        	<description><![CDATA[<p>Hello!</p>
<p>Sorry my english so bad. I try to read documentation(so hard) but i can&#39;t find answer.</p>
<p>How to save changed, deleted or added data in database?</p>
<p>Anybody can post here sources of example or attached file with sources?</p>
<p>Thanks.</p>
<p>Vitaly.</p>
]]></description>
        	        	<pubDate>Thu, 28 May 2009 13:57:18 +0300</pubDate>
        </item>
</channel>
</rss>