-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsulta2sql.php
72 lines (61 loc) · 1.49 KB
/
consulta2sql.php
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
<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Consulta 2</title>
</head>
<body>
<h1>Asistentes que atienden al menos un asistente y ninguno de los que atiende atiende a otro</h1>
<?php
require('conexion.php');
header('Content-Type: text/html; charset=UTF-8');
$query = "
SELECT *
FROM asesor AS x
WHERE 0<(SELECT count(*)
FROM asesor AS y
WHERE x.codigo = y.cliente_asesor
AND
0=(SELECT count(*)
FROM asesor AS z
WHERE y.codigo = z.cliente_asesor)
)
";
$result = mysqli_query($conexion, $query) or die(mysqli_error($conexion));
//var_dump($result);exit();
if($result){
$ultimo_equipo_id=null;
foreach ($result as $fila){
if($ultimo_equipo_id != $fila['codigo']){
$ultimo_departamento_id=$fila['codigo'];
?>
</table>
<table border='1' width=\"40%\">
<tr height='50'>
<td>Código</td>
<td>Cédula</td>
<td>Nombre</td>
<td>Salario</td>
<td>Dirección</td>
<td>Fecha de nacimiento</td>
<td>Cliente asesor</td>
<?php
}
?>
<tr>
<td><?=$fila['codigo'];?></td>
<td><?=$fila['cedula'];?></td>
<td><?=$fila['nombre'];?></td>
<td><?=$fila['salario'];?></td>
<td><?=$fila['direccion'];?></td>
<td><?=$fila['fecha_de_nacimiento'];?></td>
<td><?=$fila['cliente_asesor'];?></td>
</tr>
<?php
}
}else{
echo "Ha ocurrido un error en la consulta";
}
?>
</body>
</html>