Ver Mensaje Individual
  #4 (permalink)  
Antiguo 16/09/2009, 13:30
turfeano
 
Fecha de Ingreso: diciembre-2008
Mensajes: 190
Antigüedad: 15 años, 5 meses
Puntos: 6
Respuesta: Rellenar variables con cajas de texto

Asi puede ser
Código PHP:
if (isset($_POST['envio'])){
$fecha_inicio=$_POST['fecha_i'];
$fecha_final=$_POST['fecha_f'];

mysql_connect("localhost""root""") or die(mysql_error());
mysql_select_db("base_datos") or die(mysql_error());

$sqltgastos="SELECT sum(Gastos) FROM employee WHERE Fecha BETWEEN '$fecha_inicio' AND '$fecha_final'";
$rstgastos=mysql_query($sqltgastos);
$resTgastos=mysql_result($rstgastos,0,0);
echo 
"<br>";
echo 
"<b>Gastos ".$mes."= </b>".number_format ($resTgastos,2","".")."&euro;<br>";



}
else {
echo 
"<form method='post' action=''>";
echo 
"Fecha inicio:<input type='text' name='fecha_i' value=''>";
echo 
"Fecha fin:<input type='text' name='fecha_f' value=''>";
echo 
"<input type='submit' name='envio' value='Enviar'>";
echo 
'</form>';