Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/11/2004, 06:41
catrin
 
Fecha de Ingreso: julio-2003
Mensajes: 53
Antigüedad: 20 años, 9 meses
Puntos: 0
trabajo con datos de bd.

Hola.
Ojala puedan ayudarme.
Tengo una base de datos con ciertos valores, extraigo datos de ella según alguna condición, ahora con estos datos que extraigo quisiera calcular un poecentaje, pero no puedo trabajarlos ya que me tira un error, el script es el siguiente:

<h1><div align ="center">Datos registrados</div></h1>
<br>
<br>
<?
$a=$HTTP_POST_VARS['mesagua'];
$b=$HTTP_POST_VARS['añosagua'];
$c=$b-1;
{echo "$a";}
{echo "$b";}
{echo "$c";}
//coneccion a la base de datos
mysql_connect("localhost","root","root");
//ejecutamos sentencia sql
$resul=mysql_db_query("gestion","select consumo_h from agua where año='$b'
and mes= '$a'");
$resul2=mysql_db_query("gestion","select consumo_h from agua where año='$c'
and mes= '$a'");
?>
<table align ="center" border="2" bordercolor="blue">
<tr>
<th>mes</th>
<th> Año <?php echo $b;?></th>
<th> Año <?php echo $c;?> </th>
<th>variación</th>
<?
//Mostramos los registros
While ($row=mysql_fetch_array($resul))
While ($row2=mysql_fetch_array($resul2))
{$v=($row(consumo_h)-$row2(consumo_h));}
{
echo '<tr><td>'.$a.'</td>';
echo '<td>'.number_format($row ["consumo_h"]).'</td>';
echo '<td>'.number_format($row2["consumo_h"]).'</td>';
echo '<td>'.$v.'</td><tr>';
}
mysql_free_result($resul)
?>
</table>
<div align ="right">
<a href="gestioningenieria.html"><b>Ver más indicadores.</b></a><br>
</BODY>
</HTML>

Por favor si alguien me puede guiar se lo agreadecería mucho.

Gracias.