Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:52:19+00:00 2026-05-31T01:52:19+00:00

I’m a jQuery/jqGrid newbie… I’ve got my jqGrid selecting and displaying my data correctly.

  • 0

I’m a jQuery/jqGrid newbie…

I’ve got my jqGrid selecting and displaying my data correctly. I also have the edit/add buttons adding/editing data on my grid. However, I’m not sure how I make those adds/edits update MySQL database. Any suggestions?

Here is my scripts.js file:

 $("#table-maintenance-conflicts").jqGrid(
    { 
        url:'maintenanceConflicts.php', 
        editurl:'maintenanceConflicts-edit.php',
        datatype: 'xml',
        mtype: 'GET',
        colNames:['Conflict Code', 'Description', 'Updated By', 'Updated On'], // Set column names of the grid
        colModel :[ // Set the settings for each individual column of the grid
            {
                name:'conflictCode', 
                index:'conflictCode', 
                width:120, 
                align:'center', 
                editable:false, 
            }, 
            {name:'description', index:'description', width:200, editable:true, edittype:"text"}, 
            {name:'updatedBy', index:'updatedBy', width:120, editable:true, edittype:"text", editrules: {required: true}}, 
            {name:'updatedOn', index:'updatedOn', width:120, editable:false, editrules: {required: true}}
        ], 
        pager: '#pager-maintenance-conflicts', 
        rowNum:10, // To start, the user will see 10 records on the first page
        rowList:[10,15,20], // How many records is the user able to see per page?
        sortname: 'conflictCode',
        sortorder: 'desc', // Order the 'sortname' should be sorted in
        viewrecords: true, // View the records upon grid startup? or wait until a search?
        caption: 'Maintenance | Conflicts' // Title of the grid (at the top)
    }).navGrid('#pager-maintenance-conflicts',{
        edit:true,
        add:true,
        view:true,
        del:true,
        search:true,
        refresh:true
    });

// ADD
$("#add_table-maintenance-conflicts").click(function(){

    jQuery("#table-maintenance-conflicts").jqGrid('editGridRow',"new",{
        mtype: 'POST',
        reloadAfterSubmit:false, 
        closeAfterAdd:true,         
    });

});

// EDIT
$("#edit_table-maintenance-conflicts").click(function(){

    var gr = jQuery("#table-maintenance-conflicts").jqGrid('getGridParam','selrow');
    if( gr != null ) 
        jQuery("#table-maintenance-conflicts").jqGrid('editGridRow',gr,{
            mtype: 'POST',
            reloadAfterSubmit:false, 
            closeAfterEdit:true
        });

});

// DELETE
$("#del_table-maintenance-conflicts").click(function(){

    var gr = jQuery("#table-maintenance-conflicts").jqGrid('getGridParam','selrow');
    if( gr != null ) 
        jQuery("#table-maintenance-conflicts").jqGrid('delGridRow',gr,{
            mtype: 'POST',
            reloadAfterSubmit:false
        });

});

Here is my maintenanceConflicts-edit.php file:

<?php 

//include the information needed for the connection to MySQL data base server. 
// we store here username, database and password 
$dbhost = "localhost";

$dbuser = "root";

$dbpassword = "";

$database = "ftdbadmin";

// connect to the database
$db = mysql_connect($dbhost, $dbuser, $dbpassword) or die("Connection Error: " . mysql_error());
//echo "Connected to MySQL <br />";

// select the database
mysql_select_db($database) or die("Error conecting to db.");
//echo "Connected to the selected database: ".$database."<br />";

//  If we're ADDING
if($_POST['oper']=='add')
{

}

// If we're EDITING
if($_POST['oper']=='edit')
{
    $conflictCode     =   mysql_real_escape_string($_POST['conflictCode']);
    $description   =   mysql_real_escape_string($_POST['description']);
    $updatedBy =   mysql_real_escape_string($_POST['updatedBy']);
   // $updatedOn    =   mysql_real_escape_string($_GET['updatedOn']);

$SQL = "UPDATE tblconflict SET updatedBy = '".$updatedBy."', description = '".$description."' WHERE conflictCode = ".$conflictCode;

    echo $SQL;
    $result=mysql_query($SQL) or die(mysql_error());

    mysql_close($db);
}

// If we're DELETING
if($_POST['oper']=='del')
{

}

?>

Any help would be greatly appreciated!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:52:21+00:00Added an answer on May 31, 2026 at 1:52 am

    I managed to figure this out a few months ago by poking around the Wiki, Google, and here on this site. I stumbled across this PHP CRUD template for jQGrid. With a little tweaking, I got it working with all my grids. Once you begin to work with it more, you will notice lots of room for improvement and expansion. It should get you started in the right direction.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.