title: Can not return success message after updating the data using Angular.js and PHP
body: <p>i have one problem.I am able to update the data inside database but unable to return the success message.I am explaining my code below.</p>
  
  <pre><code>&lt;?php
  require_once("../include/dbconfig.php");
  $postdata = file_get_contents("php://input");
  $request = json_decode($postdata);
  $pro_info=$request-&gt;db_quantity_info;
  $len=count($pro_info);
  $fields=array("quantity");
  $tablename=PREFIX."product_info";
  for($i=0;$i&lt;$len;$i++){
      $pro_id=$pro_info[$i]-&gt;pro_Id;
      $quantity=$pro_info[$i]-&gt;quantity;
      $values=array($quantity);
      $condn="pro_Id='".prepare_param($pro_id)."' ";
      $id=db_update($tablename,$fields,$values,$condn);
  }
  if($id){
      $return["msg"]="updated successfully";
  }else{
     header("HTTP/1.0 401 Unauthorized");
     $return["msg"]="Unable to update";
  }
  echo json_encode($return);
  
  ?&gt;
  
  function db_update($table,$columns, $values, $condition=""){
      global $con;
      if($table=="" || $columns=="" || $values=="" || count($columns) != count($values)){
          return false;
      }
      $updatestr="";
      for($i=0;$i&lt;count($columns);$i++){
          if($updatestr==""){
              $updatestr=" SET ".$columns[$i]." = '".$con-&gt;real_escape_string($values[$i])."'";
          }else{
              $updatestr.=" , ".$columns[$i]." = '".$con-&gt;real_escape_string($values[$i])."'";
          }
      }
      if($condition !=""){
          $condition=" WHERE ".$condition;
      }
      $sql = "UPDATE ".$table." ".$updatestr.$condition;
      if($con-&gt;query($sql)){
          return $con-&gt;affected_rows;
      }else{
          return false;
      }
  }
  </code></pre>
  
  <p>Here my array of data are updating successfully but the else part is executing always.When i tested <code>$id</code> by returning it it is showing always zero.Here I need after update inside DB the success message should return.</p>