<?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: Can't Add, Edit, Delete records in Database</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1</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/cant-add-edit-delete-records-in-database-1/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>joaohcoruripe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14969</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14969</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>you guys can help me to find a link with a PHP and .js example file&#160; with navGrid search configuration?</p>
<p>I have a grid of database firebird and I can&#39;t do the search.</p>
</p>
<p>Sorry my English</p>
]]></description>
        	        	<pubDate>Fri, 19 Feb 2010 23:11:29 +0200</pubDate>
        </item>
        <item>
        	<title>richsoe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14921</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14921</guid>
        	        	<description><![CDATA[<p>Thanks guys. I finally got it working. There is also one good example (with codes) can be downloaded from this blog <a href="http://suddendevelopment.com/?p=38" rel="nofollow" target="_blank">http://suddendevelopment.com/?p=38</a>.</p>
<p>The idea is the same as the sample codes you guys posted above. You will need to write your own CRUD codes. This is somehow different from the commercial version, because it&#39;s simpler, the library handles that.</p>
<p>Anyways, the blog above should help you figure out how the CRUD works.</p>
<p>Cheers!</p>
]]></description>
        	        	<pubDate>Thu, 18 Feb 2010 03:50:40 +0200</pubDate>
        </item>
        <item>
        	<title>mstone42 on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14908</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14908</guid>
        	        	<description><![CDATA[<p>I was having this same problem and just discovered a solution.&#160;</p>
<p>Here&#39;s the code for my grid:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">$("#userlist").jqGrid({<br />&#160;&#160; &#160;&#160;&#160; &#160;&#8230;<br />&#160;&#160; &#160;&#160;&#160; &#160;url:&#39;userdata.php&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;datatype: "json",<br />&#160;&#160; &#160;&#160;&#160; &#160;colNames:[&#39;User&#39;,&#39;Password&#39;],<br />&#160;&#160; &#160;&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;userid&#39;,index:&#39;userid&#39;, key:true,editable:true,...},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;pswd&#39;,index:&#39;pswd&#39;,hidden:true,editable:true,edittype:"password",editrules:{edithidden:true},...}<br />&#160;&#160; &#160;&#160;&#160; &#160;],<br />&#160;&#160; &#160;&#160;&#160; &#160;editurl:"userdata_edit.php" ,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#8230;<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;$("#user_edit").click(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;var uid = jQuery("#userlist").jqGrid(&#39;getGridParam&#39;,&#39;selrow&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;var options = { modal: true, reloadAfterSubmit:true, &#8230; };<br />&#160;&#160; &#160;&#160;&#160; &#160;if(uid != null ) jQuery("#userlist").jqGrid(&#39;editGridRow&#39;,uid,options);<br />&#160;&#160; &#160;&#160;&#160; &#160;else alert("Please Select Row");<br />&#160;&#160; &#160;}); <br />&#160;&#160; &#160;<br />&#160;&#160; &#160;$("#user_add").click(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;var options = { modal: true, reloadAfterSubmit:true, &#8230; };<br />&#160;&#160; &#160;&#160;&#160; &#160;jQuery("#userlist").jqGrid(&#39;editGridRow&#39;,"new",options);<br />&#160;&#160; &#160;});<br />&#160;&#160; &#160;<br />&#160;&#160; &#160;$("#user_del").click(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;var uid = jQuery("#userlist").jqGrid(&#39;getGridParam&#39;,&#39;selrow&#39;);<br />&#160;&#160; &#160;&#160;&#160; &#160;var options = { modal: true, reloadAfterSubmit:true, &#8230; };<br />&#160;&#160; &#160;&#160;&#160; &#160;if(uid != null ) jQuery("#userlist").jqGrid(&#39;delGridRow&#39;, uid, options );<br />&#160;&#160; &#160;&#160;&#160; &#160;else alert("Please Select Row");<br />&#160;&#160; &#160;}); </span></p>
<p>There may be a simpler way to handle the various button definitions, but this works for me.</p>
<p>And here&#39;s is the php script specified in the &#39;editurl&#39; parameter of the grid:</p>
<p style="padding-left: 30px;"><span style="color: #0000ff;">&#60;?php</span></p>
<p>// value is one of [ add, edit, del ] &#8211; automatically provided by jqgrid<br />$action = (isset($_REQUEST[&#39;oper&#39;]) ? trim($_REQUEST[&#39;oper&#39;] ): null);</p>
<p>// only valid for oper in [ edit, del ] &#8211; automatically provided by jqgrid<br />$id = (isset($_REQUEST[&#39;id&#39;]) ? trim($_REQUEST[&#39;id&#39;] ): null);</p>
<p>// all the other fields are only included if&#160; oper in [ edit, add ]<br />$userid = (isset($_REQUEST[&#39;userid&#39;]) ? trim($_REQUEST[&#39;userid&#39;] ): null);<br />$pswd = (isset($_REQUEST[&#39;pswd&#39;]) ? trim($_REQUEST[&#39;pswd&#39;] ): null);</p>
<p>switch ($action) {</p>
<p>&#160;&#160;&#160; case "add" : // the "id" value = "_empty", which is useless to us<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $sql = "INSERT INTO Users " &#8230;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; db_query($sql, $userid, $pswd);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160; case "del" :&#160; //need to use provided "id" value, since no other values are passed in<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $sql = "DELETE FROM Administration " &#8230;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; db_query($sql, $id);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />&#160;&#160; &#160;<br />&#160;&#160;&#160; case "edit" :<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $sql = "UPDATE Administration SET " &#8230;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; db_query($sql, $pswd, $id);<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; break;<br />}</p>
<p>// generate json data object to show result of query<br />$data-&#62;page = 1;<br />$data-&#62;total = 1;$data-&#62;records = 1;</p>
<p>$data-&#62;rows[0][&#39;id&#39;]=$SQL_ERRNO;<br />$data-&#62;rows[0][&#39;cell&#39;]=array($SQL_ERRNO, $SQL_ERROR, $sql);<br />print(json_encode($data));</p>
<p>?&#62;</p>
<p style="padding-left: 30px;">&#160;</p>
<p>I don&#39;t know if the json data I&#39;m displaying for the result is what jqgrid is expecting, but that&#39;s my next task to figure out &#8211; I&#39;ll try to post my findings if someone else doesn&#39;t post something first.</p>
<p>I hope this helps.</p>
<p>-Mitch</p></p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 19:46:20 +0200</pubDate>
        </item>
        <item>
        	<title>lupin on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14900</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14900</guid>
        	        	<description><![CDATA[<blockquote>
<p>JiheL said:</p>
<p>Hello</p>
<p>I&#39;m newbie in jqGrid use, but I think that the same url in url and editurl is not correct, as editurl is used to process add, edit and del operations, and your php script don&#39;t act for that.</p>
<p>I have found this script in this forum :</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit8253' value='Select Code' data-codeid='sfcode8253' /></p>
<div class='sfcode' id='sfcode8253'>&#160;&#160;&#160;&#160;&#160; // FETCHES THE &#39;USERS&#39; TABLE DATA<br />&#160;&#160;&#160;&#160;&#160;&#160; if($_GET[oper]==&#39;sel&#39;){</p>
<p>&#160;&#160;&#160;&#160;&#160; // ADDS NEW APP RECORD &#8211; I have 5 columns, and these are the titles</p>
<p>&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;add&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ins = &#34;INSERT INTO appid (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note)&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @mysql_query($ins) or die(&#34;failed&#34;);</p>
<p>&#160;&#160;&#160;&#160;&#160; // MODIFIES USER RECORD<br />&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;edit&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $upd = &#34;UPDATE appid SET (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note) WHERE id=$id&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @mysql_query($upd) or die(&#34;failed&#34;);</p>
<p>&#160;&#160;&#160;&#160;&#160; // DELETES USER RECORD AND ASSOCIATED ACCESS RELATIONSHIPS<br />&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;del&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SQL = &#34;DELETE FROM appid WHERE id=$id&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $res = @mysql_query($SQL) or die(&#34;failed&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }&#160;&#160; &#160;</p>
</div>
<p>I hope this will help you.</p>
<p>Cheers</p>
<p>JiheL</p>
</p>
<p>PS sorry for my bad english</p>
</blockquote>
<hr />
<p>Hi ,</p>
</p>
<p>Do you have any example of the response code from the editurl? I having hard time on it as well as I can&#39;t find any examples on what it&#39;s expecting after a sucess/failed submission.</p>
</p>
<p>hopefully someone will add it on wiki, it should be like:</p>
</p>
<p>1) after submission does it suceed or failed?</p>
<p>2) what is the expected response structure of json/xml from the server.</p>
<p>3) How to load/insert on on grid incase of add/edit, refresh in grid in case of delete.</p>
</p>
<p>Thank you in advance,</p>
<p>lupin</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 15:46:06 +0200</pubDate>
        </item>
        <item>
        	<title>JiheL on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14884</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14884</guid>
        	        	<description><![CDATA[]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 12:38:35 +0200</pubDate>
        </item>
        <item>
        	<title>JiheL on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14883</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14883</guid>
        	        	<description><![CDATA[<p>Hello</p>
<p>I&#39;m newbie in jqGrid use, but I think that the same url in url and editurl is not correct, as editurl is used to process add, edit and del operations, and your php script don&#39;t act for that.</p>
<p>I have found this script in this forum :</p>
</p>
<p><input type='button' class='sfcodeselect' name='sfselectit6211' value='Select Code' data-codeid='sfcode6211' /></p>
<div class='sfcode' id='sfcode6211'>&#160;&#160;&#160;&#160;&#160; // FETCHES THE &#39;USERS&#39; TABLE DATA<br />&#160;&#160;&#160;&#160;&#160;&#160; if($_GET[oper]==&#39;sel&#39;){</p>
<p>&#160;&#160;&#160;&#160;&#160; // ADDS NEW APP RECORD &#8211; I have 5 columns, and these are the titles</p>
<p>&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;add&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ins = &#34;INSERT INTO appid (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note)&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @mysql_query($ins) or die(&#34;failed&#34;);</p>
<p>&#160;&#160;&#160;&#160;&#160; // MODIFIES USER RECORD<br />&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;edit&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $fname = $_POST[&#39;fname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $lname = $_POST[&#39;lname&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $userid = $_POST[&#39;userid&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $start = $_POST[&#39;start&#39;];<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $note = $_POST[&#39;note&#39;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $upd = &#34;UPDATE appid SET (fname,lname,userid,start,note) VALUES ($fname,$lname,$userid,$start,$note) WHERE id=$id&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; @mysql_query($upd) or die(&#34;failed&#34;);</p>
<p>&#160;&#160;&#160;&#160;&#160; // DELETES USER RECORD AND ASSOCIATED ACCESS RELATIONSHIPS<br />&#160;&#160;&#160;&#160;&#160; } elseif($_POST[oper]==&#39;del&#39;) {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $id = $_POST[&#39;id&#39;];</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SQL = &#34;DELETE FROM appid WHERE id=$id&#34;;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $res = @mysql_query($SQL) or die(&#34;failed&#34;);<br />&#160;&#160;&#160;&#160;&#160;&#160; }<br />&#160;&#160;&#160; }&#160;&#160; &#160;</p>
</div>
<p>I hope this will help you.</p>
<p>Cheers</p>
<p>JiheL</p>
</p>
<p>PS sorry for my bad english</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 12:38:33 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14868</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14868</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Please do not douple post in all forums!</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 11:59:31 +0200</pubDate>
        </item>
        <item>
        	<title>richsoe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14864</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1#p14864</guid>
        	        	<description><![CDATA[<p>How this jqGrid is actually performing search, add, edit, delete to DB? I can&#39;t get it working, I can only select.</p>
<p>If I add, edit, or delete, it just update the UI / gridview.</p>
<p><strong>Here is my table:</strong></p>
<p>CREATE TABLE `vip_queue` (&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `id` INT(11) NOT NULL AUTO_INCREMENT,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `username` VARCHAR(64) DEFAULT NULL,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `group_id` SMALLINT(3) DEFAULT NULL,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PRIMARY KEY&#160; (`id`),&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; UNIQUE KEY `username` (`username`)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ) ENGINE=INNODB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8</p>
<p><strong>Here is my Javascript:</strong></p>
<p>&#60;script type="text/javascript"&#62;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery(document).ready(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery("#list").jqGrid({<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;url:&#39;admin.vip.queue.process.php&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;datatype: "json",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;mtype: "POST",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;colNames:[&#39;vip_id&#39;,&#39;username&#39;, &#39;group_id&#39;],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;vip_id&#39;, index:&#39;vip_id&#39;, width:100, editable:false, editoptions:{readonly:true}, editrules:{required:false}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;username&#39;, index:&#39;username&#39;, width:300, editable:true, edittype:&#39;text&#39;},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;group_id&#39;, index:&#39;group_id&#39;, width:200, editable:true, edittype:&#39;text&#39;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;pager: &#39;#pagernav&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;rowNum:50,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;rowList:[10,50,100,200,500,1000],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;sortname: &#39;vip_id&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;sortorder: "asc",<br />&#160;&#160; &#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;&#160; &#160;caption: "Manage VIP Queue",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;editurl: "admin.vip.queue.process.php",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;height: 400<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; &#160;jQuery("#list").jqGrid(&#39;navGrid&#39;,&#39;#pagernav&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{}, //options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",closeAfterEdit:true,reloadAfterSubmit:true}, // edit options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",closeAfterAdd:true,reloadAfterSubmit:true}, // add options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",reloadAfterSubmit:true}, // del options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{} // search options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#60;/script&#62;</p>
</p>
<p><strong>Here is my php script:</strong></p>
<p>require_once(&#39;class/db.php&#39;);<br />$db= new db();<br />$writeConn = $db-&#62;getWriteConnection();<br />$debug = false;</p>
<p>$page = $_POST[&#39;page&#39;]; // get the requested page<br />$limit = $_POST[&#39;rows&#39;]; // get how many rows we want to have into the grid<br />$sidx = $_POST[&#39;sidx&#39;]; // get index row &#8211; i.e. user click to sort<br />$sord = $_POST[&#39;sord&#39;]; // get the direction<br />if(!$sidx) $sidx =1;</p>
<p>$sql = "SELECT COUNT(id) as count FROM vip";<br />$result = $db-&#62;query($sql, $debug, $writeConn);<br />$row = mysql_fetch_array($result);<br />$count = $row[&#39;count&#39;];</p>
<p>if( $count &#62;0 ) {<br />&#160;&#160; &#160;$total_pages = ceil($count/$limit);<br />} else {<br />&#160;&#160; &#160;$total_pages = 0;<br />}<br />if ($page &#62; $total_pages) $page=$total_pages;<br />$start = $limit*$page &#8211; $limit; // do not put $limit*($page &#8211; 1)<br />if ($start&#60;0) $start = 0;</p>
<p>$sql = "SELECT id as &#39;vip_id&#39;, username, group_id FROM vip ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit;<br />$result = $db-&#62;query($sql, $debug, $writeConn);</p>
<p>$response-&#62;page = $page; <br />$response-&#62;total = $total_pages; <br />$response-&#62;records = $count; <br />$i = 0;<br />while($row = mysql_fetch_array($result)) <br />{<br />&#160;&#160; &#160;$response-&#62;rows[$i][&#39;id&#39;]=$row[&#39;vip_id&#39;]; <br />&#160;&#160; &#160;$response-&#62;rows[$i][&#39;cell&#39;]=array($row[&#39;vip_id&#39;],$row[&#39;username&#39;],$row[&#39;group_id&#39;]); <br />&#160;&#160; &#160;$i++; &#160;&#160; &#160;<br />}<br />echo json_encode($response); <br />$db-&#62;close($writeConn);</p>
</p>
<p>Please help. Thx</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 11:41:48 +0200</pubDate>
        </item>
</channel>
</rss>