Ver Mensaje Individual
  #4 (permalink)  
Antiguo 27/07/2011, 20:56
Avatar de andresdzphp
andresdzphp
Colaborador
 
Fecha de Ingreso: julio-2011
Ubicación: $this->Colombia;
Mensajes: 2.749
Antigüedad: 12 años, 9 meses
Puntos: 793
Respuesta: Como hago este programa :(

Te hice un código espero que te sirva:

Código PHP:
Ver original
  1. <html>
  2.     <head>
  3.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  4.         <title>Compañía de Seguros</title>
  5.     </head>
  6.     <body bgcolor="#e8eff1">
  7.         <font face="Tw Cen MT">
  8.             <form name="Seguros" action="index.php" method="POST">
  9.                 Vendedores: <input type="text" name="vendedores" size="10">
  10.                 <input type="submit" value="Calcular">
  11.                 </form>
  12.         <?php
  13.         $i=1;
  14.        
  15.         if(isset($_POST{'vendedores'})){
  16.             $vendedores=$_POST{'vendedores'};    
  17.             echo '<form name="datos" action="pruebas.php" method="POST">';      
  18.             while($i<=$vendedores){
  19.                 ?>
  20.            
  21.                     <BR><BR> VENDEDOR <?php echo $i; ?> <BR>                
  22.                 venta 1: <input type="text" name="venta1[<?php echo $i; ?>]" size="10"><br>
  23.                 venta 2: <input type="text" name="venta2[<?php echo $i; ?>]" size="10"><br>
  24.                 Venta 3: <input type="text" name="venta3[<?php echo $i; ?>]" size="10"><br><br>
  25.                 Sueldo Base: <input type="text" name="salario[<?php echo $i; ?>]" size="10">
  26.          
  27.             <?php
  28.            
  29.             $i++;
  30.            
  31.             }
  32.             echo '<input type="hidden" name="vdn" value="'.$vendedores.'">';
  33.            
  34.             echo '<br><br><input type="submit" value="Calcular">';
  35.             echo '</form>';
  36.              
  37.            
  38.              }
  39.            
  40.             ?>
  41.         </font>
  42.     </body>
  43. </html>

Esta es la página donde calcula todo pruebas.php

Código PHP:
Ver original
  1. <?php  
  2.  
  3. $vendedores = $_POST['vdn'];
  4. $totalApagar = 0;
  5. $totalApagarC = 0;  
  6. $totalApagarS = 0;
  7.  
  8. for ($i=1; $i<=$vendedores; $i++) {
  9.    
  10.     $com = ($_POST['venta1'][$i]+$_POST['venta2'][$i]+$_POST['venta3'][$i])*0.10;
  11.    
  12.     echo 'Empleado ' . $i . '<br /><br />';
  13.     echo 'Comision: ' . $com;
  14.    
  15.     $totalApagarS += $_POST['salario'][$i];
  16.     $totalApagarC += $com;
  17.     $totalApagar += $com + $_POST['salario'][$i];
  18.    
  19.     echo '<br /><br />Comision + Salario: ' . $com += $_POST['salario'][$i];
  20.     echo '<hr />';
  21.    
  22. }
  23.  
  24. echo 'Total a pagar en salarios: ' . $totalApagarS . '<br />';
  25. echo 'Total a pagar en comisiones: ' . $totalApagarC . '<br />';
  26. echo 'Total a pagar a sus empleados: ' . $totalApagar . '<br />';
  27.  
  28. ?>
__________________
Si sabemos como leer e interpretar el manual será mucho más fácil aprender PHP. En lugar de confiar en ejemplos o copiar y pegar - PHP

Última edición por andresdzphp; 28/07/2011 a las 16:38 Razón: Agregando información