jQWidgets Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts

  • lammiu
    Participant

    Hi Peter,

    I tried the exact example on northwind db, everything goes well except data won’t save to mysql db. on refresh, everything no change. Please update example


    lammiu
    Participant

    Hi Ivailo,

    Thx for the prompt reply.

    The database table only has 5 column, I have modified the northwind db by removing other columns and just updating 2 field names. The rest of the code are same as php demo for server_side_grid_editing_with_popup except with the 2 updated field names for the whole file
    EmployeeID
    LastName
    Email
    Mobile
    TitleOfCourtesy


    lammiu
    Participant

    Instructor is mysql db, similar to Northwind except, I have changed the field name Title to mobile, Last name to Email

    <?php
    #Include the connect.php file
    include(‘connect.php’);
    #Connect to the database
    //connection String
    $connect = mysql_connect($hostname, $username, $password)
    or die(‘Could not connect: ‘ . mysql_error());
    //Select The database
    $bool = mysql_select_db($database, $connect);
    if ($bool === False){
    print “can’t find $database”;
    }
    // get data and store in a json array
    $query = “SELECT * FROM instructor”;

    if (isset($_POST[‘update’]))
    {
    // UPDATE COMMAND
    $update_query = “UPDATE ‘instructor’ SET FirstName='”.mysql_real_escape_string($_POST[‘FirstName’]).”‘,
    Email='”.mysql_real_escape_string($_POST[‘Email’]).”‘,
    Mobile='”.mysql_real_escape_string($_POST[‘Mobile’]).”‘ WHERE EmployeeID='”.mysql_real_escape_string($_POST[‘EmployeeID’]).”‘”;
    $result = mysql_query($update_query) or die(“SQL Error 1: ” . mysql_error());
    echo “in update”;
    console.log(“in update”);
    echo $result;
    }
    else
    {
    // SELECT COMMAND
    $result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $employees[] = array(
    ‘EmployeeID’ => $row[‘EmployeeID’],
    ‘FirstName’ => $row[‘FirstName’],
    ‘Email’ => $row[‘Email’],
    ‘Mobile’ => $row[‘Mobile’]
    );
    }

    echo json_encode($employees);
    }
    ?>

Viewing 3 posts - 1 through 3 (of 3 total)