Te hice un código espero que te sirva:
Código PHP:
Ver original<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Compañía de Seguros</title>
</head>
<body bgcolor="#e8eff1">
<font face="Tw Cen MT">
<form name="Seguros" action="index.php" method="POST">
Vendedores: <input type="text" name="vendedores" size="10">
<input type="submit" value="Calcular">
</form>
<?php
$i=1;
if(isset($_POST{'vendedores'})){ $vendedores=$_POST{'vendedores'};
echo '<form name="datos" action="pruebas.php" method="POST">';
while($i<=$vendedores){
?>
<BR><BR> VENDEDOR <?php echo $i; ?> <BR>
venta 1: <input type="text" name="venta1[<?php echo $i; ?>]" size="10"><br>
venta 2: <input type="text" name="venta2[<?php echo $i; ?>]" size="10"><br>
Venta 3: <input type="text" name="venta3[<?php echo $i; ?>]" size="10"><br><br>
Sueldo Base: <input type="text" name="salario[<?php echo $i; ?>]" size="10">
<?php
$i++;
}
echo '<input type="hidden" name="vdn" value="'.$vendedores.'">';
echo '<br><br><input type="submit" value="Calcular">';
echo '</form>';
}
?>
</font>
</body>
</html>
Esta es la página donde calcula todo pruebas.php
Código PHP:
Ver original<?php
$vendedores = $_POST['vdn'];
$totalApagar = 0;
$totalApagarC = 0;
$totalApagarS = 0;
for ($i=1; $i<=$vendedores; $i++) {
$com = ($_POST['venta1'][$i]+$_POST['venta2'][$i]+$_POST['venta3'][$i])*0.10;
echo 'Empleado ' . $i . '<br /><br />';
echo 'Comision: ' . $com;
$totalApagarS += $_POST['salario'][$i];
$totalApagarC += $com;
$totalApagar += $com + $_POST['salario'][$i];
echo '<br /><br />Comision + Salario: ' . $com += $_POST['salario'][$i];
echo '<hr />';
}
echo 'Total a pagar en salarios: ' . $totalApagarS . '<br />';
echo 'Total a pagar en comisiones: ' . $totalApagarC . '<br />';
echo 'Total a pagar a sus empleados: ' . $totalApagar . '<br />';
?>