Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_TopicIcon
Need some help Using Form Editing
16/06/2009
10:18
Avatar
KiMbOoO
Member
Members
Forum Posts: 7
Member Since:
07/06/2009
sp_UserOfflineSmall Offline

Hi !

Sorry for my bad english !

So i'm using jQgrid 3.5 beta build 5 and i have some troubles whith Form Editing in order to save the result in my database. When i whant to edit/delete row in my grid, change is done on my grid but not on my database.

Maybe i forget something … somebody can help me please

There is my code of grid :

—-

    $('#list2').jqGrid({
    url:'../library/Request/modifconge.php?id=<?php echo $this->escape($this->iduser);?>',
    datatype: 'xml',
    colNames:['Annee', 'Conge','Debut','Fin','Jour','Saisie le','Statut','PDF'],
    colModel :[ {name:'annee_conge', index:'annee_conge', width:60, align: 'center',
                  editable:true,
                 editoptions:{size:"5",maxlength:"4"}
                 },
                {name:'libelle_type_conge', index:'libelle_type_conge', width:220, align: 'left'},
                {name:'date_debut', index:'date_debut', width:140, align: 'center',
                 editable:true,
                 editoptions:{
                 size:12,
                 dataInit:function(el){
                        $(el).datepicker({dateFormat:'yy-mm-dd'});
                                    },
                defaultValue: function(){
                        var currentTime = new Date();
                        var month = parseInt(currentTime.getMonth() + 1);
                        month = month <= 9 ? "0"+month : month;
                        var day = currentTime.getDate();
                        day = day <= 9 ? "0"+day : day;
                        var year = currentTime.getFullYear();
                        return year+"-"+month + "-"+day;
                        }
                }},
                {name:'date_fin', index:'date_fin', width:140, align: 'center',
                 editable:true,
                 editoptions:{
                 size:12,
                 dataInit:function(el){
                        $(el).datepicker({dateFormat:'yy-mm-dd'});
                                    },
                defaultValue: function(){
                        var currentTime = new Date();
                        var month = parseInt(currentTime.getMonth() + 1);
                        month = month <= 9 ? "0"+month : month;
                        var day = currentTime.getDate();
                        day = day <= 9 ? "0"+day : day;
                        var year = currentTime.getFullYear();
                        return year+"-"+month + "-"+day;
                        }
                }},
                {name:'nbre_jour', index:'nbre_jour', width:60, align: 'center',
                 editable:true,
                 editoptions:{size:"2",maxlength:"2"}
                 },
                {name:'date_avis_conge', index:'date_avis_conge', formatter:'date', width:140, align:'center'},
                {name:'etat_conge', index:'etat_conge', width:100, align:'center'},
                {name:'PDF', index:'PDF', width:60, align:'center'}],
    pager: $('#pager2'),
    rowNum:10,
    height:300,
    editurl:'../library/Request/editconge.php',
    sortname: 'id_avis_conge',
    sortorder: “desc”,
    viewrecords: true,
    caption: ''
    }).navGrid('#pager2',
    {edit:true,add:false,del:true,view:true,search:false}, //options
    {reloadAfterSubmit:false,jqModal:false, closeOnEscape:true,url:'../library/Request/editconge.php'}, //edit options
    {reloadAfterSubmit:false,jqModal:false, closeOnEscape:true}, //add options
    {reloadAfterSubmit:false,jqModal:false, closeOnEscape:true,url:'../library/Request/editconge.php'}, // del options
    {closeOnEscape:true}, // search options
    {height:250,jqModal:false,closeOnEscape:true} // view options
    );

—–

and there is my code php of server-side editconge.php :

<?php
//Informations pour se connecter à la BDD
$dbhost= 'localhost';
$dbuser ='root';
$dbpassword = '';
$database = 'gestpresent';

//Connexion à la BDD
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die(”Connection Error: ” . mysql_error());
 
//Sélection de la base de donnée à utiliser
mysql_select_db($database) or die(”Error connecting to db.”);

//Récupération de l'ID de la ligne à modifier
$id=mysql_real_escape_string($_POST['id']);
$fields = '';
$value = '';

$exceptions='submit, id, ';

//format input POST fields into SQL syntax for the list of fields and values after SET
foreach ($_POST as $field => $value) {
    if (!preg_match(”/$field, /”, $exceptions)) {
        $value = mysql_real_escape_string($value);
        $fields .= “$field = '$value', “;
        }
    }
$fields = preg_replace('/, $/', '', $fields);

$queryedit = “UPDATE avis_conge SET $fields WHERE id_avis_conge='$id'”;

$querydel = “DELETE FROM avis_conge WHERE id_avis_plan='$id'”;

// EDIT
if($_REQUEST[oper]=='edit') {
    if (mysql_query($queryedit))
  {
  echo 'Edited';
  }
else
  {
  echo 'Error editing : '. mysql_error();
  }

// DELETE
} elseif($_POST[oper]=='del') {
   if (mysql_query($querydel))
  {
  echo 'Deleted';
  }
else
  {
  echo 'Error deleting: '. mysql_error();
  }

 }

?>

16/06/2009
10:49
Avatar
KiMbOoO
Member
Members
Forum Posts: 7
Member Since:
07/06/2009
sp_UserOfflineSmall Offline

it's good ! i found my mistake ! it was in my php server-side !

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
95 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information