jQWidgets Forums
Forum Replies Created
-
Author
-
Hi Peter Stoev,
Thanks for your answer!!!
Best Regards,
bachkylanHi Dimitar, Thanks for your reply!
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.
<br />hebergeur image<br /><br />
I hope you ‘ll understand my problem.
Thanks!
January 29, 2015 at 3:38 am in reply to: jqxGrid/json data – can't figure out what's wrong jqxGrid/json data – can't figure out what's wrong #66156I 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 INTOnhanvien
(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 = “UPDATEnhanvien
SETIDNV
='”.$_GET[‘idnv’].”‘,
MaNV
='”.$_GET[‘manv’].”‘,
TenNV
='”.$_GET[‘tennv’].”‘,
DienThoai
='”.$_GET[‘dienthoai’].”‘WHEREIDNV
='”.$_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 FROMnhanvien
WHEREIDNV
='”.$_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);
}
});
}
}; -
AuthorPosts