Jqgrid可以编辑但不能添加

时间:2013-12-17 18:35:10

标签: php mysql jqgrid

我的网格正在运行,我可以编辑数据,但我无法添加新的数据行。当我提交添加表单时没有任何反应,我在PHPMyAdmin页面上得不到任何回复,以显示网格是使用INSERT语句命中数据库的。

这是我的编辑代码。

    <?php

$dbhost = "localhost"; 
$dbuser = "root"; 
$dbpass = "*****"; 
$dbname = "******"; 

// connect to the database
$conn = mysqli_connect($dbhost, $dbuser, $dbpass) or die("Connection Error: " . mysql_error());
mysqli_select_db($conn,$dbname) or die("Error conecting to db.");

//$id = "'".$_POST['id']."'";
$unit = "'".$_POST['unit_id']."'";
$div = "'".$_POST['div_id']."'";
$titleorg = "'".$_POST['title_org']."'";
$shortdesc = "'".$_POST['short_desc']."'";
$longdesc = "'".$_POST['long_desc']."'";
$unitdesc = "'".$_POST['unit_desc']."'";
$enabled = "'".$_POST['avail_ind']."'";
$active = "'Y'";


switch($_POST['oper'])
{
    case "add":
        $query = "INSERT INTO depunits (unit_id, div_id, title_org, short_desc, long_desc, unit_desc, avail_ind,active_ind) values ($div,$unit,$titleorg,$shortdesc,$longdesc,$unitdesc,$enabled,$active)";
        mysqli_query($conn,$query);
    break;

    case "edit":
        $query = "UPDATE depunits SET unit_id=$unit,div_id=$div,title_org=$titleorg,short_desc=$shortdesc,long_desc=$longdesc,unit_desc=$unitdesc,avail_ind=$enabled where unit_id=$unit";
        mysqli_query($conn,$query); 
    break;
}

?>

0 个答案:

没有答案