Obtener datos de un distrito y mostrar datos consultados a una base de datos
Publicado por Daniel (2 intervenciones) el 16/04/2019 20:30:08
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
<?php
$codigo='getDistrito';
$consulta=mysqli_query($cn,"SELECT descripcion FROM distrito WHERE id_distrito='$codigo'")or die("Problemas con el select".mysqli_error($cn));
$distrito=mysqli_fetch_assoc($consulta,0);
//Implementando la consulta
$sql='SELECT c.id_cliente as "id", CONCAT(c.nombres,"",c.paterno,"",c.materno) as "datos",c.fono as "fono",d.descripcion as "distrito" FROM CLIENTE C INNER JOIN DISTRITO D on c.id_distrito=d.id_distrito where c.id_distrito="'.$codigo.'"';
//Realizando la consulta en base al distrito seleccionado
$rsC=mysqli_query($cn,$sql) or die("Problemas obteniendo datos".mysqli_error($cn));
//Determinar el total de clientes
$total=mysqli_num_rows($rsC);
?>
<p id="centrado">Clientes del Distrito: <?php echo $distrito; ?></p>
<table border="0" width=700 cellspacing="1" cellpadding="1">
<tr>
<th>CODIGO</th>
<th>CLIENTE</th>
<th>TELEFONO</th>
<th>DISTRITO</th>
</tr>
<?php
for ($i=0; $i < $total; $i++) {
?>
<tr>
<td><?php echo mysqli_use_result($rsC, $i, 0) ?></td>
<td><?php echo mysqli_use_result($rsC, $i, 1) ?></td>
<td><?php echo mysqli_use_result($rsC, $i, 2) ?></td>
<td><?php echo mysqli_use_result($rsC, $i, 3) ?></td>
</tr>
<?php } ?>
<tr>
<td></td>
<td></td>
<th>TOTAL</th>
<th><?php echo $total ?></th>
</tr>
</table>
</form>
Valora esta pregunta


0