title: if/else for non-duplicate of data
body: <p>Im having a problem, it seems my codes are incorrect. All i want is that to prevent the duplication of data. In this array submit form result, if the user already have already the kind of row, he can only insert data that are not in the table. My current code will not insert all data. But if remove the if else statements, all the data within the loop can be inserted.</p>
  
  <pre><code>    if(isset($_POST['submit']))
      {
          $var_emp_id = $_POST["emp_id"];
          $var_task_id = $_POST["task_id"];
          $var_weight = $_POST['weight'];
          $submit=$_POST['submit'];
  
          for ($i = 0; $i &lt;= count($var_emp_id); $i++)
          {
              $sql=mysql_query("SELECT emp_id,task_id FROM peval_tbl WHERE emp_id = '$var_emp_id[$i]' AND task_id = '$task_id[$i]'");
  
              while($row=mysql_fetch_assoc($sql))
              {
  
                  $emp_id = $row['emp_id'];
                  $task_id = $row['task_id'];
  
                  if ($var_emp_id[$i] ==  $emp_id &amp;&amp; $var_task_id[$i] == $task_id){
                  mysql_query("INSERT IGNORE INTO peval_tbl(weight,task_id,emp_id)                         VALUES('$var_weight[$i]','$var_task_id[$i]','$var_emp_id[$i]')");                                  
  
              }
          else{   
              error_reporting(E_ALL ^ E_NOTICE);
  
              for ($i = 0; $i &lt;= count($var_emp_id); $i++)
          {
          mysql_query("INSERT INTO peval_tbl(weight,task_id,emp_id)                         VALUES('$var_weight[$i]','$var_task_id[$i]','$var_emp_id[$i]')");
  
          }
          }
          }
      }
      }
  </code></pre>