
Multiplicar un valor de un bucle por
Publicado por diego (9 intervenciones) el 06/06/2016 01:32:56
Si bien parece que tiene logica, no da el numero que deberia, y tampoco puedo descubrir o no me doy cuenta como lo esta haciendo .. La idea seria que el valor mensual que se obtienen en $c se multiplique por $pesos (por la linea 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<!DOCTYPE HTML>
<html>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<head>
<title>RESULTADO</title>
</head>
<body>
<br><br>
<?php
$a=$_POST['suscrip']; //DECLARA VARIABLE a
$b=$_POST['meses']; // DECLARA VARIABLE b
$pesos=90;
echo "<h1>". "Estos son las proyecciones calculadas". "<p>"."</h1>" ;
echo "<table class='table table-striped'>"; //EMPIEZA A CREAR LA TABLA CON LOS ENCABEZADOS DE TABLA
echo "<tr>";//<tr> CREA UNA NUEVA FILA
$c = 0;
for ($r=0; $r<=$b; $r++) //BUCLE
{
if ($c == 0) // CONDICION VARIABLE C Y SE VA FIJANDO VARIABLE A
{
$c = $a;
} else
{
echo "<td>"."mes".'  '. $r. '  '.'</br>'.$c .' '.'</br>'."</td>"; //IMPRIME ESTA LINEA
$c = $c + $a;
}
}
//NUEVO BLOQUE--------------------------------
echo "</table>";//FINALIZA LA TABLA s
echo "<table class='table table-striped'>"; //EMPIEZA A CREAR LA TABLA CON LOS ENCABEZADOS DE TABLA
echo "<tr>";//<tr> CREA UNA NUEVA FILA
$c = 0;
for ($r=0; $r<=$b; $r++)
{ //BUCLE
if ($c == 0){ // CONDICION VARIABLE C Y SE VA FIJANDO VARIABLE A
$c = $a;
}
else {
echo "<td>".$c .' '.'</br>'."</td>"; //IMPRIME ESTA LINEA
$c = $c + $a * $pesos;
}
}
echo "</table>";//FINALIZA LA TABLA s
echo "</tr>";
//SACAR TODO ESTE BLOQUE--------------------------------------
?>
</body>
</html>
Valora esta pregunta


0