写这么多,真的不好看呀,楼主,增加不成功时,看看你的提示错误,根据提示,去改问题,不过不成功的原因也就是以下几个:一是没有传值过去,二就是值传过去,但是变量没有写对,三就是数据类型错误,你最好在你的增加完成的那个页面先进行输出看看有没有值,问题就解决了

解决方案 »

  1.   

    现在我把adddelmok.php代码改成了下面的,可以每次只能添加进一条选中的记录.
    <?
    require ("config.php");
    $names = $addname;foreach($names as $key=>$name){
    $sql="select programpath from distributeprogram where filename='$name'";
    if(mysql_num_rows(mysql_query($sql))>=1) 
    unset($names[$key]);
    }
    $str = "'".implode("','",$names)."'";
    if($str=="''") die('计划文件已存在或者没有新条目要添加!');$sql="select max(planid) maxid from distributeprogram";
    @$result=mysql_query($sql);
    while($rs=mysql_fetch_object($result)){
         $startId = $rs->maxid+1;
    }
    if($startId==0) $startId = 1;for($j=0;$j<count($addname);$j++){ 
         $tmp[] = "('$startId','".$addname[$j]."','$aimpath')";
    }
    require ("config.php");
    $query = "insert into distributeprogram(planid,filename,aimpath) values ";
    if(!is_array($tmp)) die('提交的信息中没有要进行添加');
    $query .= implode(',', $tmp);
    @$result=mysql_query($query);require ("config.php");
    $sql2="select max(planid) maxid from distributeplan";
    @$result2=mysql_query($sql2);while($rs=mysql_fetch_object($result2)){
         $startId2 = $rs->maxid+1;
    }
    if($startId==0) $startId = 1;
    $query="insert into distributeplan(planid,sourceip,targetip,setplantime,execplantime,closeplantime,enabled,plankind,username) values('$startId2','$sourceip','$targetip','$setplantime','$execplantime','$closeplantime','$enabled','$plankind','$username')";
    @$result=mysql_query($query);
    if ($result)
       echo "<font color=red>恭喜您!成功添加记录!</font>";
    else
       echo "<meta http-equiv='refresh' content='2; url=addplan.php'><font color=red>添加失败!系统正在返回,请稍候...</font>";
    ?>