-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdadostratados.php
More file actions
109 lines (97 loc) · 4.59 KB
/
dadostratados.php
File metadata and controls
109 lines (97 loc) · 4.59 KB
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
<?php
print "
<h1 style='margin-top:5%; text-align:center;'>Monitoramento de Dados em tempo Real</h1>
";
$resultado_pes = "SELECT * FROM `dados`";//select do banco de dados da tabela cadastro
$pesquisa_nome = mysqli_query($conn, $resultado_pes); //conexao com o banco de dados
$sql = "SELECT * FROM `dados` ORDER BY `app_id`.`dev_id`. `hardware_serial`.`port`.`counter`.`payload_raw`.`rfid` DESC"; //ordenando o select
$res = $conn -> query($resultado_pes); //resposta do banco de dados
$qtd = $res -> num_rows; //exibir a quantidade de cadastrados
//estilo de exibição de pesquisa
print "
<div class='container' style='margin-top: 8%;'>
<!--foi colocado um style na tag para afastar as tabelas do topo-->
<div class='row'>
<div class='col'>
<!--Tabela de entrada, aqui defeine a largura do Grid em 50% -->
<h2 style='text-align:center;'>Entrada</h2>
<!--Titulo da tabela-->
<table class='table table-striped table-bordered'>
<!-- aqui inicia a tabela de saída-->
<thead>
<tr>
<th scope='col' style='width:6%; text-align:center'>$qtd</th>
<th scope='col' style='width: 15.2%; text-align:center;'>add_id</th>
<th scope='col' style='width: 15.2%; text-align:center;'>dev_id</th>
<th scope='col' style='width: 20.8%; text-align:center;'>hardware_serial</th>
<th scope='col' style='width:7.6%; text-align:center'>port</th>
<th scope='col' style='width:7.6%; text-align:center'>counter</th>
<th scope='col' style='width: 12.2%; text-align:center;'>payload_raw</th>
<th scope='col' style='text-align:center;'>rfid</th>
</tr>
</thead>
</table>
</div>
";
//pesquisa do banco com resultado de quantidade
while($rows_pesquisa = mysqli_fetch_array($pesquisa_nome)){
if($qtd > 0){//se o valor for maior que zero vai exibir
while($row = $res -> fetch_assoc()){
//print "foi encontrado " .$row["nomeUsuario"]. $row["setor"];
print "
<div class='container' style='margin-top: -1.5%;'>
<div class='row'>
<div class='col-12'>
<table class='table table-striped table-bordered'>
<tbody>
<tr>
<th scope='row' style='width:2%; text-align:center;'>$row[idDado]</th>
<td scope='row' style='width:10%;text-align:center;'>$row[app_id]</td>
<td scope='row' style='width:10%; text-align:center;'>$row[dev_id]</td>
<td scope='row' style='width:10%; text-align:center;'>$row[hardware_serial]</td>
<td scope='row' style='width:5%; text-align:center;'>$row[port]</td>
<td scope='row' style='width:5%; text-align:center;'>$row[counter]</td>
<td scope='row' style='width:8%; text-align:center;'>$row[payload_raw]</td>
<td scope='row' style='width:10%; text-align:center;'>$row[rfid]</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>";//fim da lista
/* print "
<div class='container' style='margin-top: -1.5%;'>
<div class='row'>
<div class='col-6'>
<table class='table table-striped table-bordered'>
<tbody>
<tr>
<th scope='row'>1</th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<td>setor</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>";*/
}
}else{
print "<p>Resultado não entrado</p>";//caso não tenha resultado para ser exibido
}
}
/*function pegardados($decoded){
$fp2 = fopen('data2.txt', 'a');//opens file in append mode
$app = $decoded["app_id"];
$dev = $decoded["dev_id"];
$hard = $decoded["hardware_serial"];
$por = $decoded["port"];
$cout = $decoded["counter"];
$payR = $decoded["payload_raw"];
fwrite($fp2, "insert into dados (app_id, dev_id, hardware_serial, port, counter, payload_raw) values ('{$app}', '{$dev}', '{$hard}', '{$por}', '{$cout}', '{$payR}')");
$sql = "insert into dados (app_id, dev_id, hardware_serial, port, counter, payload_raw) values ('{$app}', '{$dev}', '{$hard}', '{$por}', '{$cout}', '{$payR}')";//insere no banco
$result = $conn ->query($sql);//faz a conexão com o banco
}*/
?>