1
I have a table
registro
structured
'id(AI)', 'b1(INT 2)', 'b2(INT 2)', 'b3(INT 2)', 'b4(INT 2)', 'b5(INT 2)'
which receives the values entered in the FORM of the insert.php page,
example how data is saved:
'ID=1','12','13','6','7','2'
'ID=2','6','7','1','7','15'
on the table classes
with the structure 'id(AI)', 'nome(TEXT)'
already have the data entered as pre '1,a','2,b','3,c'...'20,t'
respectively.
I am trying to count how many times the ID’s as they are inserted repeat and always list the 10 that repeat less.
My application is PHP, the index.php page is like this:
<?php session_start();
include_once("conexao.php");
date_default_timezone_set('America/Sao_Paulo');
$date = date('d-m-Y');
$datec = date('Y-m-d');
?>
<!doctype html>
<html lang="pt-br">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>estudo teste</title>
<link rel="stylesheet" href="../adm/assets/libs/css/style.css">
<link rel="stylesheet" href="../adm/assets/vendor/bootstrap/css/bootstrap.min.css">
</head>
<body>
<?php
$query = "SELECT * FROM classes ORDER BY id ASC";
$resultado = mysqli_query($conectar, $query);
while($linhas = mysqli_fetch_assoc($resultado)){
$id = $linhas['id'];
$nome = $linhas['nome'];
$total = "SELECT * FROM registros WHERE b1='$id' OR b2='$id' OR b3='$id' OR b4='$id' OR b5='$id'";
$resultado_total = mysqli_query($conectar, $total);
$total = mysqli_num_rows($resultado_total);
if($total != ''){
echo $nome." / ".$total."<br> ";
}}
?>
</body>
</html>
at the moment I can only count how many times it repeats itself, the intention is to return more or less like this:
Resultado ID 12-i = 1
Resultado ID 01-a = 1
Resultado ID 07-g = 2
...
edited with the information you requested .
– Ronaldo de Lima