Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/07/2009, 16:47
manupalaya
 
Fecha de Ingreso: enero-2007
Mensajes: 156
Antigüedad: 17 años, 3 meses
Puntos: 3
Respuesta: Mostrar consulta mysql en php

Ya tengo la respuesta espero os sirva:

Código PHP:
<?php
//***** Calculo de Gastos por medio de una sentencia mysql compleja****
$link mysql_connect("localhost""usuario""password");

mysql_select_db("nombre_basedatos"$link);

$result mysql_query("SELECT categoria_gastos.categoria_gastos, SUM(employee.Gastos), Gastos FROM categoria_gastos INNER JOIN employee USING (id_categoria_gastos) WHERE (YEAR(employee.Fecha) = 2009 AND MONTH(employee.Fecha) = 7) GROUP BY employee.id_categoria_gastos"$link);

if (
$row mysql_fetch_array($result)){

echo 
"<table border = '1'> \n";

echo 
"<tr> \n";

echo 
"<td><b>categoria_gastos</b></td> \n";

echo 
"<td><b>Gastos</b></td> \n";

echo 
"</tr> \n";

do {

echo 
"<tr> \n";

echo 
"<td>".$row["categoria_gastos"]."</td> \n";

echo 
"<td>".$row["Gastos"]."</td>\n";

echo 
"</tr> \n";

} while (
$row mysql_fetch_array($result));

echo 
"</table> \n";

} else {

echo 
"¡ La base de datos está vacia !";

}

?>