<?php
    if(($_GET['op']!='666')){
      die();
    }
    ini_set('display_errors',on);
   include_once('./protected/config/db.conf.php');
   $conn = mysql_connect($dbconfig['dev'][0], $dbconfig['dev'][2], $dbconfig['dev'][3]);
   mysql_set_charset('utf8',$conn);
   mysql_select_db($dbconfig['dev'][1],$conn);
    if(isset($_GET['del'])){
      $delsql = 'SELECT * FROM jl_measure_numofper where pmid='.$_GET['del'].' AND numpname='.$_GET['np'].' AND times='.$_GET['time'];
      $result3 = mysql_query($delsql, $conn);
      $num_rows = mysql_num_rows($result3);
      echo $num_rows;
      if($num_rows == 0){
        mysql_query('DELETE FROM jl_measure_audit WHERE pmid='.$_GET['del'].' AND numpname='.$_GET['np'].' AND times='.$_GET['times'],$conn);
        echo '已删除';
      }else{
        echo '不能删除';
      }
    }
   if(isset($_POST['sel'])){
     $sql2 = "SELECT * FROM jl_measure_numofper where pmid=".$_POST['sel'].' order by mpid desc limit 1';
     $result2 = mysql_query($sql2,$conn);
     while ($row2 = mysql_fetch_array($result2)) {
      echo 'border:'.$row2['pmid'].'_'.$row2['numpname'].'_'.$row2['times'].'<br>';
      }
      $sql2 = "SELECT * FROM jl_measure_audit where pmid=".$_POST['sel'].' order by maid desc limit 1';
      $result2 = mysql_query($sql2,$conn);
      while ($row2 = mysql_fetch_array($result2)) {
       echo 'audit:'.$row2['pmid'].'_'.$row2['numpname'].'_'.$row2['times'].'<br>'.'<a href="/zh.php?del='.$row2['pmid'].'&np='.$row2['numpname'].'&time='.$row2['times'].'">删除</a>';
       }
   }
   $sql = "SELECT * FROM jl_project_measure";
   $result = mysql_query($sql,$conn);
   while ($row = mysql_fetch_array($result)) {
    $rowArray[] = $row;
    }
?>
<html>
<meta charset="utf-8" />
<head>
  <title>
    删除未提交数据
  </title>
</head>
<body>
  <form method="post">
  <select name="sel">
    <option>选择要干掉的标段
    </option>
<?php
$optionHtml = '';
foreach ($rowArray as $key => $value) {
     $optionHtml .= '<option value="'.$value['pmid'].'">'.$value['pmname'].'</option>';
}
echo $optionHtml;
?>
</select>
<input type="submit" value="干掉它">
</form>
</body>
</html>
<?php
mysql_free_result($result);
mysql_close($conn);
 ?>
