jQWidgets Forums

Forum Replies Created

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • in reply to: post data into database post data into database #66909

    bachkylan
    Participant

    Hi Peter Stoev,

    Thanks for your answer!!!

    Best Regards,
    bachkylan

    in reply to: help me about combobox help me about combobox #66162

    bachkylan
    Participant

    Hi Dimitar, Thanks for your reply!

    It same as demo ,

    I ‘ve two column as this photo, I choose value to “Tên hàng” column, then “Mã SP” column show respectively value with index of “Tên hàng ” column

    I can get index of “Tên hàng” column but i don’t know set index for “Mã SP” column.

    Untitled 2<br />hebergeur image<br /><br />

    I hope you ‘ll understand my problem.

    Thanks!


    bachkylan
    Participant

    I think it can help you, pls try!

    PHP : nhap_nhanvien.php

    <?php
    #Include the connect.php file
    include(‘connect.php’);
    #Connect to the database
    //connection String
    $connect = mysql_connect($db_host, $db_username, $db_password)
    or die(‘Could not connect: ‘ . mysql_error());
    //Select The database
    $bool = mysql_select_db($db_name, $connect);
    if ($bool === False){
    print “can’t find $db_name”;
    }

    if (isset($_GET[‘insert’])){
    // INSERT COMMAND
    $insert_query = “INSERT INTO nhanvien(IdNV,MaNV, TenNV,DienThoai) VALUES (‘”.$_GET[‘idnv’].”‘,'”.$_GET[‘manv’].”‘,'”.$_GET[‘tennv’].”‘,'”.$_GET[‘dienthoai’].”‘)”;
    $result = mysql_query($insert_query) or die(“SQL Error 1: ” . mysql_error());
    echo $result;
    }else if (isset($_GET[‘update’])){
    // UPDATE COMMAND
    $update_query = “UPDATE nhanvien SET IDNV='”.$_GET[‘idnv’].”‘,
    MaNV='”.$_GET[‘manv’].”‘,
    TenNV='”.$_GET[‘tennv’].”‘,
    DienThoai='”.$_GET[‘dienthoai’].”‘WHERE IDNV='”.$_GET[‘idnv’].”‘”;
    $result = mysql_query($update_query) or die(“SQL Error 1: ” . mysql_error());
    echo $result;
    }
    else if (isset($_GET[‘delete’])){
    // DELETE COMMAND
    $delete_query = “DELETE FROM nhanvien WHERE IDNV='”.$_GET[‘idnv’].”‘”;
    $result = mysql_query($delete_query) or die(“SQL Error 1: ” . mysql_error());
    echo $result;
    }else{
    // SELECT COMMAND
    $result = mysql_query($query) or die(“SQL Error 1: ” . mysql_error());
    while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $khachhang[] = array(
    ‘IDNV’ => $row[‘idnv’],
    ‘MaNV’ => $row[‘manv’],
    ‘TenNV’ => $row[‘tennv’],
    ‘DienThoai’ => $row[‘dienthoai’]
    );
    }
    echo json_encode($khachhang);
    }
    ?>

    HTML :
    var source =
    {
    datatype: “json”,
    datafields: [
    { name: ‘idnv’ },
    { name: ‘manv’ },
    { name: ‘tennv’ },
    { name: ‘dienthoai’ }
    ],
    id: ‘idnv’,
    url: ‘php/get_data_nhan_vien.php’,
    cache: false,
    addrow: function (rowid, rowdata, position, commit) {
    var data = “insert=true&” + $.param(rowdata);
    $.ajax({
    dataType: ‘json’,
    url: ‘php/nhap_nhanvien.php’,
    data: data,
    cache: false,
    success: function (data, status, xhr) {
    commit(true);
    },
    error: function (jqXHR, textStatus, errorThrown) {
    commit(false);
    }
    });
    },
    deleterow: function (rowid, commit) {
    // synchronize with the server – send delete command
    var data = “delete=true&” + $.param({ idnv: rowid });
    $.ajax({
    dataType: ‘json’,
    url: ‘php/nhap_nhanvien.php’,
    cache: false,
    data: data,
    success: function (data, status, xhr) {
    // delete command is executed.
    commit(true);
    },
    error: function (jqXHR, textStatus, errorThrown) {
    commit(false);
    }
    });
    },
    updaterow: function (rowid, rowdata, position, commit) {
    // synchronize with the server – send update command
    var data = “update=true&” + $.param(rowdata);
    $.ajax({
    dataType: ‘json’,
    url: ‘php/nhap_nhanvien.php’,
    cache: false,
    data: data,
    success: function (data, status, xhr) {
    // update command is executed.
    commit(true);
    },
    error: function (jqXHR, textStatus, errorThrown) {
    commit(false);
    }
    });
    }
    };

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