jQ Grid problems with edit form does not send request to the SQL database

kurtpercy

New Member
I am a new user of jQ Grid and I would like to implement an edit form. My grid is currently linked to a SQL Database. The data of the SQL Database are correctly displayed in the grid.When I select a row and click on the edit button, an edit form is appearing with data of the selected row. When I'm modifying the information and click submit, the modification is displayed on the grid but my ** SQL database is not updated**. If I refresh the page, the grid will display the information of the SQL Database and I can see that my modifications have not been made in the database (The data displayed are the same as those initially displayed ).Can someone help me out with that ?Here is my grid code :\[code\]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>My First Grid</title> <link rel="stylesheet" type="text/css" media="screen" href="http://stackoverflow.com/questions/15824142/jquery-ui-1.10.2/themes/base/jquery.ui.all.css" /><link rel="stylesheet" type="text/css" media="screen" href="http://stackoverflow.com/questions/15824142/css/ui-lightness/jquery-ui-1.8.2.custom.css" /><link rel="stylesheet" type="text/css" media="screen" href="http://stackoverflow.com/questions/15824142/ui.jqgrid.css" /><style type="text/css">html, body { margin: 0; padding: 0; font-size: 75%;}</style><script src="http://stackoverflow.com/questions/15824142/js/jquery-1.9.0.min.js" type="text/javascript"></script><script src="http://stackoverflow.com/questions/15824142/js/i18n/grid.locale-en.js" type="text/javascript"></script><script src="http://stackoverflow.com/questions/15824142/js/jquery.jqGrid.min.js" type="text/javascript"></script><script src="http://stackoverflow.com/questions/15824142/js/jquery.jqGrid.src.js" type="text/javascript"></script><script type="text/javascript">jQuery.extend(jQuery.jgrid.defaults, { autoencode:true });</script><script type="text/javascript">$(function(){ $("#editgrid").jqGrid({ url:'example.php', datatype: 'xml', mtype: 'GET', colNames:['Numero','Nature', 'Nom','Qualification','PrixMax','PrixMin'], colModel :[ {name:'Numero', index:'Numero', width:55,cellEdit:true, celledittype:'text'}, {name:'Nature', index:'Nature', editable: true, edittype: 'text', editoptions: { size: 10}, editrules: {required: true }, formoptions: { label: 'Nature' }, width:90}, {name:'Nom', index:'Nom', width:180, align:'right',editable: true,edittype:'textarea'}, {name:'Qualification', index:'Qualification', width:80, align:'right',editable: true,edittype:'textarea'}, {name:'PrixMax', index:'PrixMax', width:80, align:'right',editable: true,edittype:'textarea'}, {name:'PrixMin', index:'PrixMin', width:150, sortable:false,editable: true,edittype:'textarea'} ], pager: '#pager', rowNum:10, rowList:[10,20,30], sortname: 'Numero', sortorder: 'desc', viewrecords: true, emptyrecords: "Nothing to display", gridview: true, editurl:'edit.php', edittype:'text', caption: 'My first grid', loadonce:true,}); $("#bedata").click(function(){ var gr = jQuery("#editgrid").jqGrid('getGridParam','selrow'); if( gr != null ) jQuery("#editgrid").jqGrid('editGridRow',gr,{height:280,reloadAfterSubmit:false,edit:true},{editurl:'edit.php',mtype:'POST'}); else alert("Please Select Row");});}); </script></head><body><table id="editgrid"><tr><td/></tr></table> <div id="pager"></div> <input type="BUTTON" id="bedata" value="http://stackoverflow.com/questions/15824142/Edit Selected" /></body></html>\[/code\]And here is the edit.php which is supposed to update my database :\[code\]<?php$dbhost ="localhost";$dbuser="root";$dbpassword="";$database="geoclients";$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error()); mysql_select_db($database) or die("Error connecting to db."); $tablename="clients";mysql_set_charset('utf8',$database);mysql_query("SET NAMES 'utf8'"); $Num = mysql_real_escape_string($_POST['Numero']); $Nat = mysql_real_escape_string($_POST['Nature']); $Nom = mysql_real_escape_string($_POST['Nom']); $Qual = mysql_real_escape_string($_POST['Qualification']); $PrixMax = mysql_real_escape_string($_POST['PrixMax']); $PrixMin = mysql_real_escape_string($_POST['PrixMin']); $sql = "UPDATE ".$tablename." SET Nature = '".$Nat."', Nom = '".$Nom."', Qualification = '".$Qual."', PrixMax = '".$PrixMax."' , PrixMin = '".$PrixMin."' WHERE Numero = ".$Num.";"; echo $sql;$result=mysql_query($sql) or die(mysql_error());mysql_close($db);?>\[/code\]The connexion to the database is the same code used to fill the grid in the first place (which is working), so I'm assuming this connexion code is working. I have also checked the SQL syntax of the request which seems ok. My SQL Database is hosted on a local wamp server.Thank you in advance.
 
Top