2012-09-18 2 views
0

는 여기에 양식을 제출할 때jqGrid : 탐색기에 행 추가를 사용하여 데이터베이스에 데이터를 삽입하는 방법은 무엇입니까?

$("table#list").jqGrid({ 
url:'example.php', 
datatype: 'json', 
mtype: 'POST', 
colNames:['ID', 'Position', 'Abrv', 'Department'], 
colModel :[ 
{name:'id', index:'id', width:40, hidden: true, editrules:{edithidden:true}}, 
{name:'position', index:'position', width:300, editable: true, required: true}, 
{name:'abvr', index:'abvr', width:50, editable: true, required: true}, 
{name:'department', index:'department', editable: true, edittype: 'select', editoptions:{dataUrl: 'test2.php'}} 
], 
width: 600, 
height: 250, 
rownumbers: true, 
pager: '#pager', 
rowNum: 10, 
rowList:[10,20], 
sortname: 'id', 
sortorder: 'ASC', 
viewrecords: true, 
gridview: true, 
caption: 'Position', 
loadError : function(xhr,st,err) { 
$("#rsperror").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText); 
}, 
editurl: 'insertDB.php' 
}); 

insertDB.php

if($_POST['oper'] == 'add'){ 
$position = $_POST['position']; 
$department = $_POST['department']; 

$query = "INSERT INTO test_position VALUES ('', '$position', '$department')"; 
$run = mysql_query($query); 
} 

아무런 변화가 없습니다 내 jQuery를 스크립트입니다. 내 데이터베이스도 마찬가지로 업데이트되지 않습니다.

  1. PHP의 내 게시물 변수가 올바르지 않습니까?
  2. insertDB.php를 가져와 jQuery에서 표시하는 방법이 있습니까?

답변

0

데이터베이스를 선택하는 것을 잊었습니다. 나는 FireBug를 사용한 후에 발견했다.

관련 문제