Web lists-archives.com

[PHP] error Undefined index:




I have an error with a variable in $ _POST that I can not find how to solve it

This is the error

Notice: Undefined index: empresa in /var/www/jobs/ganancia_por_empresa_mes.php on line 34

This is the query

<?php

$empresa = $_POST['empresa'];
$mes = $_POST['meses'];
$anio = $_POST['anio'];



if ( $_POST ) {
$result=pg_query("SELECT empresa, sum(valor) valor FROM trabajos WHERE empresa='$empresa' and to_char(fecha, 'TMMONTH')::varchar = '$mes' and date_part('year', fecha)= '$anio'
group by empresa");
$registros= pg_num_rows($result);

}
?>

<div align="center">
  <table border="1" cellpadding="1">
    <tr>
      <td><strong>Empresa</strong></td>
      <td><strong>Total</strong></td>
     
    </tr>
   
<?php
//mostrar resultados
for ($i=0;$i<$registros;$i++)
{

$row = pg_fetch_array ($result,$i );

//}
?>
      <tr>
      <td>
        <?php
  echo $row['empresa'];
  ?>
      </td>
      <td>$
        <?php
  echo $row['valor'];
   }
     ?>
  </td>
  
   </tr>
 
  </table>

</div>


<div align="center" ><a href="ganancia_empresa_mes.php">Volver</a></div>
</body>

</html>

The error of line 34 is this:

$empresa = $_POST['empresa'];

Thanks




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php