Evitar repetir líneas de tabla html sobre un tabla de mysql en php
Publicado por jose (71 intervenciones) el 24/02/2021 10:12:08
Intento hacer un código en donde pueda crear una tabla en html de forma que automáticamente cree líneas de la tabla hasta el final del campo. Lo he intentado con un for pero no hay forma
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
<caption>GASTOS POR CATEGORIAS</caption>
<tbody>
<?php
$query = "select * from viaje WHERE viaje_nombre= '".$Reg."'";
$result = mysqli_query($conn,$query);
while($row=$result->fetch_assoc()){
$tipo = $row['tipo'];
?>
<tr>
<th><?php $tipo ?></th>
<!-- TOTAL -->
<td><?php $query="SELECT CONCAT(SUM(cantidad), ' €') '".$tipo."' FROM viaje WHERE tipo = '".$tipo."' and viaje_nombre= '".$Reg."'";
$result = mysqli_query($conn,$query);
//Si no hay gasto poner '0 €'
if (!empty($tipo)){
echo $tipo; ?></td>
<?php } else {
echo '0 €'; ?></td>
<?php } ?>
</tr>
<?php } //FIN FOR ?>
</tbody>
Valora esta pregunta


0