<?php
session_start();
if( $_SESSION["user"] == "" || $_SESSION["passwd"] == "" ) {
//   header("Location: index.php");
}

$Mov = isset($_POST['key']) ? $_POST["key"]  : ""; 

include_once('db_config.php');
ini_set('max_execution_time', 120);

   if( strlen($Mov) > 0 ) {

      $first = true;
      $sql = "select sql_no_cache movimientos.id, movimientos.cuenta, denominacion, deber, haber from movimientos left joinf cuentas on cuentas.cuenta=movimientos.cuenta where movimientos.id= '" . $Mov . "' and borrado=0";
//      echo $sql;
      $result = $conn->query($sql);
      if ($result->num_rows > 0) {
         if( $row = $result->fetch_assoc() ) {
            echo "{\"id\":\"" . $row["id"] . "\",";
            echo  "\"cuenta\":\"" . $row["cuenta"] . "\",";
            echo  "\"denominacion\":\"" . $row["denominacion"] . "\",";
            echo  "\"deber\":\"" . $row["deber"] . "\",";
            echo  "\"haber\":\"" . $row["haber"] . "\",";
            echo  "\"observa\":\"" . $row["observa"] . "\"}";
         }
      }
      else echo "[]";
      mysql_free_result( $result ); 
   }
   mysqli_close($conn);
?>

