error al multiplicar y sumar en php
Publicado por Felipe (23 intervenciones) el 13/03/2020 19:32:45
hola soy nuevo en php necesito multiplicar la cantidad y sumar esos resultados para obener un Total este es el codigo que tengo
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
$products = ProductData::getAll();
$meseros = UserData::getAllMeseros();
?>
<section class="content">
<div class="row">
<div class="col-md-12">
<h1>Reportes</h1>
<form>
<input type="hidden" name="view" value="reports">
<div class="row">
<div class="col-md-3">
<select name="product_id" class="form-control">
<option value="">-- TODOS --</option>
<?php foreach($products as $p):?>
<option value="<?php echo $p->id;?>"><?php echo $p->name;?></option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-3">
<input type="date" name="sd" value="<?php if(isset($_GET["sd"])){ echo $_GET["sd"]; }?>" class="form-control">
</div>
<div class="col-md-3">
<input type="date" name="ed" value="<?php if(isset($_GET["ed"])){ echo $_GET["ed"]; }?>" class="form-control">
</div>
<div class="col-md-3">
<input type="submit" class="btn btn-success btn-block" value="Procesar">
</div>
</div>
</div>
</div>
<br><!--- -->
<div class="row">
<div class="col-md-12">
<?php if(isset($_GET["sd"]) && isset($_GET["ed"]) ):?>
<?php if($_GET["sd"]!=""&&$_GET["ed"]!=""):?>
<?php
$operations = array();
if($_GET["product_id"]==""){
$operations = OperationData::getAllByDateOfficial($_GET["sd"],$_GET["ed"]);
}
else{
$operations = OperationData::getAllByDateOfficialBP($_GET["product_id"],$_GET["sd"],$_GET["ed"]);
}
?>
<?php if(count($operations)>0):?>
<table class="table table-bordered">
<thead>
<th>Id</th>
<th>Producto</th>
<th>Cantidad</th>
<th>Precio</th>
<th>Operacion</th>
<th>Fecha</th>
</thead>
<?php foreach($operations as $operation):?>
<tr>
<td><?php echo $operation->id; ?></td>
<td><?php echo $operation->getProduct()->name; ?></td>
<td><?php echo $operation->q; ?></td>
<td>$ <?php echo $operation->getProduct()->price_out; ?></td>
<td><?php echo $operation->getOperationType()->name; ?></td>
<td><?php echo $operation->created_at; ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php else:
// si no hay operaciones
?>
<script>
$("#wellcome").hide();
</script>
<div class="jumbotron">
<h2>No hay operaciones</h2>
<p>El rango de fechas seleccionado no proporciono ningun resultado de operaciones.</p>
</div>
<?php endif; ?>
<?php else:?>
<script>
$("#wellcome").hide();
</script>
<div class="jumbotron">
<h2>Fecha Incorrectas</h2>
<p>Puede ser que no selecciono un rango de fechas, o el rango seleccionado es incorrecto.</p>
</div>
<?php endif;?>
<?php endif; ?>
</div>
</div>
<br>
<form id="form2" name="form2" method="post" action="">
<label>
<input type="submit" name="Submit" value="Imprimir" onclick="window.print();" />
</label>
</form>
<br><br><br>
</section>
Valora esta pregunta


0