title: Print a Conditioned COUNT query with PHP
body: <p>I need some help with PHP, i wanna print a value from a <code>COUNT(*)</code> query but it's conditioned, my code:</p>
  
  <pre><code>&lt;?php 
      require ('../login/conexion.php');
  
      session_start();
      if(!isset($_SESSION["id_usuario"])){
          header("location: ../login/");
      }
      //I wanna do this
      $consulta_OD = '';
      function query_()
          {
              global $conexion, $consulta_OD;
              $sql = 'SELECT COUNT(*) as total from gok_registro WHERE estado=3';
              return $conexion-&gt;query($sql);
          }
  
      $consulta_OD = query_OD();
      $costo_OD = $consulta_OD-&gt;fetch_assoc();
      echo $costo_OD['total'];                                 
  ?&gt;
  </code></pre>
  
  <p>By the way, the connection to a BD is good since my code works, without the lines after the "//i wanna do this" comment. The query also works in the console.</p>
  
  <p>The last line is to print the query in another part of the document, any help?</p>