0 Usuarios y 2 Visitantes están viendo este tema.
Amigo expesimen.Noto ke tienes un diseño algo herrado de tus tablas.en fecha 1 y 2 deberias tener date asi como lo tienes en le campo fecha cualkier campo ke represente dinero deberia ser decimal o numeric.Con respecto a la salida de la fecha no tienesp or ke usar un explode si mysql te da una funcion para eso checka "date_format()" el query mismo debe devolverte la fecha ya formateada a tu gusto.con respecto a lo de los totales despues ke corrijar lo ke he mensionadopuedes totalizar asi.select campo1,sum(el campo a sumar) as total from tabla (where si aplica) goup by campo1te recomiendo hagas un review de tu tabla y colokes los datatypes correctos
mysql es muy completo a la hora de dar formatos y trabajar con fechas por ahi he visto a muchos enrollados haciendo funciones complicadas en php cuando un datediff o alguna otra funciona bien aplicada te resuelve el rollo :-S
bueno si es verdad hay muchas cosas de mysql que mysql resuelve sencilamente y no hay que usar tantas funciones de php sino que tratar el dato que se obtiene, amigo exepecimen aunque mysql te ayude no esta de mas que verifiques los link ya que pueden ser de ayuda en otro momento de java no conosco nada pero en php hay una funcion para dar formato a numeros numbert_format http://translate.google.co.ve/translate?hl=es&sl=en&u=http://php.net/manual/es/function.number-format.php&ei=m9CWTNbFF4K8lQeP07inCg&sa=X&oi=translate&ct=result&resnum=1&ved=0CBsQ7gEwAA&prev=/search%3Fq%3Dnumber_format%2Bphp%26hl%3Des ahi te dejo un link ve si en java tienen algo parecido que lo mas seguro es que si saludos
<script>function dp(price) { string = "" + price; number = string.length - string.indexOf('.'); if (string.indexOf('.') == -1) return string + '.00'; if (number == 1) return string + '00'; if (number == 2) return string + '0'; if (number > 3) return string.substring(0,string.length-number+3);return string;}function calculate(){document.calculo.trimestre.value = dp((document.calculo.montoanual1.value)*(document.calculo.cantidad.value)/4)document.calculo.montoanual1.value = dp((document.calculo.Vinmueble.value)*(document.calculo.escala.value)/100)document.calculo.t1.value = dp((document.calculo.t2.value)-(document.calculo.t2.value)*(document.calculo.Ut1.value)/100-(document.calculo.dt1.value))document.calculo.t2.value = dp((document.calculo.t3.value)-(document.calculo.t3.value)*(document.calculo.Ut2.value)/100-(document.calculo.dt2.value))document.calculo.t3.value = dp((document.calculo.t4.value)-(document.calculo.t4.value)*(document.calculo.Ut3.value)/100-(document.calculo.dt3.value))document.calculo.t4.value = dp((document.calculo.t5.value)-(document.calculo.t5.value)*(document.calculo.Ut4.value)/100-(document.calculo.dt4.value))document.calculo.t5.value = dp((document.calculo.t6.value)-(document.calculo.t6.value)*(document.calculo.Ut5.value)/100-(document.calculo.dt5.value))document.calculo.t6.value = dp((document.calculo.montoanual1.value)-(document.calculo.montoanual1.value)*(document.calculo.Ut6.value)/100)document.calculo.suma1.value = dp(eval(document.calculo.t1.value) + eval (document.calculo.t2.value)+ eval (document.calculo.t3.value)+ eval (document.calculo.t4.value)+ eval (document.calculo.t5.value)+ eval (document.calculo.t6.value))document.calculo.multa1.value = dp((document.calculo.suma1.value)*(document.calculo.multa.value)/100)document.calculo.total.value = dp(eval(document.calculo.suma1.value)+ eval (document.calculo.multa1.value)+ eval (document.calculo.trimestre.value))}</script>
<?php $ar[1] = array("cero"=>"tomate","uno"=>"1","dos"=>"2","tres"=>"3"); $ar[2] = array("cero"=>"cebolla","uno"=>"11","dos"=>"22","tres"=>"33"); $ar[3] = array("cero"=>"platano","uno"=>"111","dos"=>"222","tres"=>"333"); $ar[4] = array("cero"=>"aji","uno"=>"1111","dos"=>"2222","tres"=>"3333"); /*Este array simula el resultado de una tabla $ar = mysql_fetch_array( mysql_query("tu query") ); hechale un ojo al bucle y ve como hago las sumatorias */ ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>Test</title><style type="text/css"><!--body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14px;}--></style></head><body><table width="1076" border="1"> <tr> <td width="125">Producto</td> <td width="258">Junio</td> <td width="231">Julio</td> <td width="208">Agosto</td> <td width="220">Junio + Julio + Agosto </td> </tr><?phpforeach( $ar as $v){?> <tr> <td><?=$v['cero']?></td> <td><?=$v['uno']?> BsF.</td> <td><?=$v['dos']?> BsF.</td> <td><?=$v['tres']?> Bs.F </td> <td><?=$v['uno'] + $v['dos'] + $v['tres']?> BsF. </td> </tr><?php$a += $v['uno'];$b += $v['dos']; $c += $v['tres']; }?> <tr> <td> </td> <td>total <?=$a?> BsF. </td> <td>total <?=$b?> BsF. </td> <td>total <?=$c?> BsF. </td> <td> </td> </tr></table></body></html>
http://phpjs.org/functions/number_format:481 esa es la función number_format implementada en js. La documentación http://php.net/manual/es/function.number-format.php. En esa pagina puedes encontrar casi todas la funciones PHP escritas en Js
Con respecto a lo del formato del numero el amigo Expecimen debería crear un thread aparte.Es solo mi opinión así el tema original llevara un hilo entendible.
observando un poco tu trabajo te puedo dar esta alternativa para llegar a lo ke vos kerés.Puedes verlo trabajando aqui http://68.233.4.180/ex.php espero entiendas el ejemplo.Código: [Seleccionar]<?php $ar[1] = array("cero"=>"tomate","uno"=>"1","dos"=>"2","tres"=>"3"); $ar[2] = array("cero"=>"cebolla","uno"=>"11","dos"=>"22","tres"=>"33"); $ar[3] = array("cero"=>"platano","uno"=>"111","dos"=>"222","tres"=>"333"); $ar[4] = array("cero"=>"aji","uno"=>"1111","dos"=>"2222","tres"=>"3333"); /*Este array simula el resultado de una tabla $ar = mysql_fetch_array( mysql_query("tu query") ); hechale un ojo al bucle y ve como hago las sumatorias */ ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /><title>Test</title><style type="text/css"><!--body,td,th { font-family: Arial, Helvetica, sans-serif; font-size: 14px;}--></style></head><body><table width="1076" border="1"> <tr> <td width="125">Producto</td> <td width="258">Junio</td> <td width="231">Julio</td> <td width="208">Agosto</td> <td width="220">Junio + Julio + Agosto </td> </tr><?phpforeach( $ar as $v){?> <tr> <td><?=$v['cero']?></td> <td><?=$v['uno']?> BsF.</td> <td><?=$v['dos']?> BsF.</td> <td><?=$v['tres']?> Bs.F </td> <td><?=$v['uno'] + $v['dos'] + $v['tres']?> BsF. </td> </tr><?php$a += $v['uno'];$b += $v['dos']; $c += $v['tres']; }?> <tr> <td> </td> <td>total <?=$a?> BsF. </td> <td>total <?=$b?> BsF. </td> <td>total <?=$c?> BsF. </td> <td> </td> </tr></table></body></html>
$consulto = mysql_query($sql,$conexio);$nusuarios = mysql_num_rows($consulto);
<?php echo $nusuarios;?>
include('ln.php');
<?php // FUnCIONES DE CONVERSION DE NUMEROS A LETRAS. fUnction céntimos() { global $importe_parcial; $importe_parcial = number_format($importe_parcial, 2, ".", "") * 100; if ($importe_parcial > 0) $num_letra = " Bolívares con ".decena_céntimos($importe_parcial); else $num_letra = " Bolívares"; return $num_letra; } fUnction Unidad_céntimos($numero) { switch ($numero) { case 9: { $num_letra = "nueve céntimos"; break; } case 8: { $num_letra = "ocho céntimos"; break; } case 7: { $num_letra = "siete céntimos"; break; } case 6: { $num_letra = "seis céntimos"; break; } case 5: { $num_letra = "cinco céntimos"; break; } case 4: { $num_letra = "cuatro céntimos"; break; } case 3: { $num_letra = "tres céntimos"; break; } case 2: { $num_letra = "dos céntimos"; break; } case 1: { $num_letra = "un céntimo"; break; } } return $num_letra; } fUnction decena_céntimos($numero) { if ($numero >= 10) { if ($numero >= 90 && $numero <= 99) { if ($numero == 90) return "Noventa céntimos"; else if ($numero == 91) return "Noventa y Un céntimos"; else return "Noventa y ".Unidad_céntimos($numero - 90); } if ($numero >= 80 && $numero <= 89) { if ($numero == 80) return "Ochenta céntimos"; else if ($numero == 81) return "Ochenta y Un céntimos"; else return "Ochenta y ".Unidad_céntimos($numero - 80); } if ($numero >= 70 && $numero <= 79) { if ($numero == 70) return "Setenta céntimos"; else if ($numero == 71) return "Setenta y Un céntimos"; else return "Setenta y ".Unidad_céntimos($numero - 70); } if ($numero >= 60 && $numero <= 69) { if ($numero == 60) return "Sesenta céntimos"; else if ($numero == 61) return "Sesenta y Un céntimos"; else return "Sesenta y ".Unidad_céntimos($numero - 60); } if ($numero >= 50 && $numero <= 59) { if ($numero == 50) return "Cincuenta céntimos"; else if ($numero == 51) return "Cincuenta y Un céntimos"; else return "Cincuenta y ".Unidad_céntimos($numero - 50); } if ($numero >= 40 && $numero <= 49) { if ($numero == 40) return "Cuarenta céntimos"; else if ($numero == 41) return "Cuarenta y Un céntimos"; else return "Cuarenta y ".Unidad_céntimos($numero - 40); } if ($numero >= 30 && $numero <= 39) { if ($numero == 30) return "Treinta céntimos"; else if ($numero == 91) return "Treinta y Un céntimos"; else return "Treinta y ".Unidad_céntimos($numero - 30); } if ($numero >= 20 && $numero <= 29) { if ($numero == 20) return "Veinte céntimos"; else if ($numero == 21) return "VeintiUn céntimos"; else return "Veinti".Unidad_céntimos($numero - 20); } if ($numero >= 10 && $numero <= 19) { if ($numero == 10) return "Diez céntimos"; else if ($numero == 11) return "Once céntimos"; else if ($numero == 11) return "Doce céntimos"; else if ($numero == 11) return "Trece céntimos"; else if ($numero == 11) return "Catorce céntimos"; else if ($numero == 11) return "Quince céntimos"; else if ($numero == 11) return "DieciSeis céntimos"; else if ($numero == 11) return "Diecisiete céntimos"; else if ($numero == 11) return "Dieciocho céntimos"; else if ($numero == 11) return "Diecinueve céntimos"; } } else return Unidad_céntimos($numero); } fUnction Unidad($numero) { switch ($numero) { case 9: { $num = "Nueve"; break; } case 8: { $num = "Ocho"; break; } case 7: { $num = "Siete"; break; } case 6: { $num = "Seis"; break; } case 5: { $num = "Cinco"; break; } case 4: { $num = "Cuatro"; break; } case 3: { $num = "Tres"; break; } case 2: { $num = "Dos"; break; } case 1: { $num = "Uno"; break; } } return $num; } fUnction decena($numero) { if ($numero >= 90 && $numero <= 99) { $num_letra = "Noventa "; if ($numero > 90) $num_letra = $num_letra."y ".Unidad($numero - 90); } else if ($numero >= 80 && $numero <= 89) { $num_letra = "Ochenta "; if ($numero > 80) $num_letra = $num_letra."y ".Unidad($numero - 80); }else if ($numero >= 70 && $numero <= 79) { $num_letra = "Setenta "; if ($numero > 70) $num_letra = $num_letra."y ".Unidad($numero - 70); } else if ($numero >= 60 && $numero <= 69) { $num_letra = "Sesenta "; if ($numero > 60) $num_letra = $num_letra."y ".Unidad($numero - 60); } else if ($numero >= 50 && $numero <= 59) { $num_letra = "Cincuenta "; if ($numero > 50) $num_letra = $num_letra."y ".Unidad($numero - 50); } else if ($numero >= 40 && $numero <= 49) { $num_letra = "Cuarenta "; if ($numero > 40) $num_letra = $num_letra."y ".Unidad($numero - 40); } else if ($numero >= 30 && $numero <= 39) { $num_letra = "Treinta "; if ($numero > 30) $num_letra = $num_letra."y ".Unidad($numero - 30); } else if ($numero >= 20 && $numero <= 29) { if ($numero == 20) $num_letra = "Veinte "; else $num_letra = "Veinti".Unidad($numero - 20); } else if ($numero >= 10 && $numero <= 19) { switch ($numero) { case 10: { $num_letra = "Diez "; break; } case 11: { $num_letra = "Once "; break; } case 12: { $num_letra = "Doce "; break; } case 13: { $num_letra = "Trece "; break; } case 14: { $num_letra = "Catorce "; break; } case 15: { $num_letra = "Quince "; break; } case 16: { $num_letra = "Dieciséis "; break; } case 17: { $num_letra = "Diecisiete "; break; } case 18: { $num_letra = "Dieciocho "; break; } case 19: { $num_letra = "Diecinueve "; break; } } } else $num_letra = Unidad($numero); return $num_letra; } fUnction centena($numero){ if ($numero >= 100) { if ($numero >= 900 & $numero <= 999) { $num_letra = "Novecientos "; if ($numero > 900) $num_letra = $num_letra.decena($numero - 900); } else if ($numero >= 800 && $numero <= 899) { $num_letra = "Ochocientos "; if ($numero > 800) $num_letra = $num_letra.decena($numero - 800); } else if ($numero >= 700 && $numero <= 799){ $num_letra = "Setecientos "; if ($numero > 700) $num_letra = $num_letra.decena($numero - 700); } else if ($numero >= 600 && $numero <= 699) { $num_letra = "Seiscientos "; if ($numero > 600) $num_letra = $num_letra.decena($numero - 600); } else if ($numero >= 500 && $numero <= 599) { $num_letra = "Quinientos "; if ($numero > 500) $num_letra = $num_letra.decena($numero - 500); } else if ($numero >= 400 && $numero <= 499) { $num_letra = "Cuatrocientos "; if ($numero > 400) $num_letra = $num_letra.decena($numero - 400); } else if ($numero >= 300 && $numero <= 399) { $num_letra = "Trescientos "; if ($numero > 300) $num_letra = $num_letra.decena($numero - 300); } else if ($numero >= 200 && $numero <= 299) {$num_letra = "Doscientos "; if ($numero > 200) $num_letra = $num_letra.decena($numero - 200); } else if ($numero >= 100 && $numero <= 199) { if ($numero == 100) $num_letra = "Cien "; else $num_letra = "Ciento ".decena($numero - 100); } } else $num_letra = decena($numero); return $num_letra; } fUnction cien() { global $importe_parcial; $parcial = 0; $car = 0; while (substr($importe_parcial, 0, 1) == 0) $importe_parcial = substr($importe_parcial, 1, strlen($importe_parcial) - 1); if ($importe_parcial >= 1 && $importe_parcial <= 9.99) $car = 1; else if ($importe_parcial >= 10 && $importe_parcial <= 99.99) $car = 2; else if ($importe_parcial >= 100 && $importe_parcial <= 999.99) $car = 3; $parcial = substr($importe_parcial, 0, $car); $importe_parcial = substr($importe_parcial, $car); $num_letra = centena($parcial).céntimos(); return $num_letra; } fUnction cien_mil() { global $importe_parcial; $parcial = 0; $car = 0; while (substr($importe_parcial, 0, 1) == 0) $importe_parcial = substr($importe_parcial, 1, strlen($importe_parcial) - 1); if ($importe_parcial >= 1000 && $importe_parcial <= 9999.99) $car = 1; else if ($importe_parcial >= 10000 && $importe_parcial <= 99999.99) $car = 2; else if ($importe_parcial >= 100000 && $importe_parcial <= 999999.99) $car = 3; $parcial = substr($importe_parcial, 0, $car); $importe_parcial = substr($importe_parcial, $car); if ($parcial > 0) { if ($parcial == 1) $num_letra = "mil "; else $num_letra = centena($parcial)." mil "; } return $num_letra; }fUnction millon() {global $importe_parcial; $parcial = 0; $car = 0; while (substr($importe_parcial, 0, 1) == 0) $importe_parcial = substr($importe_parcial, 1, strlen($importe_parcial) - 1); if ($importe_parcial >= 1000000 && $importe_parcial <= 9999999.99) $car = 1; else if ($importe_parcial >= 10000000 && $importe_parcial <= 99999999.99) $car = 2; else if ($importe_parcial >= 100000000 && $importe_parcial <= 999999999.99) $car = 3; $parcial = substr($importe_parcial, 0, $car); $importe_parcial = substr($importe_parcial, $car); if ($parcial == 1) $num_letras = "Un mill?n "; else $num_letras = centena($parcial)." millones "; return $num_letras; } fUnction convertir_a_letras($numero) { global $importe_parcial; $importe_parcial = $numero; if ($numero < 1000000000) { if ($numero >= 1000000 && $numero <= 999999999.99) $num_letras = millon().cien_mil().cien(); else if ($numero >= 1000 && $numero <= 999999.99) $num_letras = cien_mil().cien(); else if ($numero >= 1 && $numero <= 999.99) $num_letras = cien(); else if ($numero >= 0.01 && $numero <= 0.99) { if ($numero == 0.01) $num_letras = "Un céntimo"; else $num_letras = convertir_a_letras(($numero * 100)."/100")." céntimos"; } } return $num_letras; } ?>
Bueno soy algo pecador al emitir opiniones ya ke te confieso ke no se de ke va tu aplicación.pero me hago estas preguntas.¿Es necesario tu app sea web? de ser si ¿por ke razon?Hay otras opciones de rapido desarrollo que en poco time pueden solucionarte lo ke kerés resolver con javascript y el reporte de corte de caja ke se mencionaba al inicio (Considerando sea una app para uso en tu red.)por otro lado al menos yo me he hecho un ocho leyendo este tema ya ke primero se me habla de un reporte y despues saltan a otra cosa al menos yo me he hecho bolas con ello Te recomendaria un nuevo post para lo segundo donde explikes bien los procedimientos que deseas ejecfuar.