$con=mysql_query("consulta por dias...") while($arr=mysql_fetch_row($con)){ . . codigo de factura .. }