Cita:
Iniciado por quimfv
Código PHP:
Ver original//tu versión
echo " SELECT SUM(material) as material
FROM (SELECT realizacion,material FROM facturas
UNION ALL
SELECT realizacion,material FROM facturas_2011
UNION ALL
SELECT realizacion,material FROM facturas_2012)
WHERE realizacion BETWEEN '$FInicio' AND '$FFin' <br />";
$result = mysql_query("SELECT SUM(datos.material) as material ". "FROM (SELECT f.realizacion,f.material FROM facturas f ".
"UNION ALL ".
"SELECT f11.realizacion,f11.material FROM facturas_2011 f11 ".
"UNION ALL ".
"SELECT f12.realizacion,f12.material FROM facturas_2012 f12) as datos ".
"WHERE datos.realizacion BETWEEN '".$FInicio."' AND '".$FFin."';");
//versión mejorada
echo "SELECT SUM(datos.material) as material ".
"FROM (SELECT f.realizacion,f.material FROM facturas f ".
"UNION ALL ".
"SELECT f11.realizacion,f11.material FROM facturas_2011 f11 ".
"UNION ALL ".
"SELECT f12.realizacion,f12.material FROM facturas_2012 f12) as datos ".
"WHERE datos.realizacion BETWEEN '".$FInicio."' AND '".$FFin."';<br />"
Pon los alias... ejecuta la query directamente en el servidor para ver que error te da.... imprime la sentencia y asegurate que hay los
blancos que tiene que haber...
"SELECT SUM(datos.material) as material ".<--este
blanco (despues de material y antes de las ")
y cambia de equipo quizas es culpa de MOU

quimfv, gracias por tú interes pero me sigue dando error en la linea 17
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource :
Código PHP:
Ver original<?php
$FInicio= $_POST['FInicio'];
$FFin = $_POST['FFin'];
$result = mysql_query("SELECT SUM(datos.material) as material ". "FROM (SELECT f.realizacion,f.material FROM facturas f ".
"UNION ALL ".
"SELECT f11.realizacion,f11.material FROM facturas_2011 f11 ".
"UNION ALL ".
"SELECT f12.realizacion,f12.material FROM facturas_2012 f12) as datos ".
"WHERE datos.realizacion BETWEEN '".$FInicio."' AND '".$FFin."';");
{
$n++;
$iva=$row['iva'];
$total=$row['total'];
$realizacion=$row['realizacion'];
$material=$row['material'];
$id_aviso=$row['id_aviso'];
$marcas=$row['marcas'];
echo"<br>";
echo"<hr>";
echo "<h2 align='center' > FG DESDE $FInicio HASTA $FFin</h2>" ;
echo "<h2 align='center' >TOTAL FACTURADO MATERIAL FG </h2>" ;
echo "<head>
<meta http-equiv='content-type' content='text/html; charset=ISO-8859-1' />
<title>formulario_tabla</title>
</head>
<body >
<form method='post' action='actualizar_pedido.php'
name='entrada'>
<table border='0' width='100%' style='background-color:#BEBEBE '>
<tbody>
<tr>
<td style='text-align: center;'><small>TOTAL MATERIAL FG </small></td>
</tr>
<tr>
<td style='width: 120px; text-align: center;'><input
size='10' name='material' value='$material'></td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
";
}
?>