As I could count the repeated fields in my table, I tried that way more did not work:
Holds the name of the genres
$generos = mysqli_query($conn,"SELECT * FROM 'generos'");
while($res = mysqli_fetch_assoc($generos)){
$nomeGenero = $res['nome_genero'];
$nomeGeneroCaracteres = $res['nome_genero'];
$gn = [rtrim(''.$nomeGenero.'',',')];
foreach ($gn as $epAtual){
@$generoAtual = $urlE[1];
$contaGeneros = mysqli_query($conn,"SELECT * FROM 'seriados'");
while($row = mysqli_fetch_assoc($contaGeneros)){
$genero = $row['genero_serie'];
$conta = mysqli_num_rows($genero);
if($generoAtual == $epAtual){
$epAtual = preg_replace('/[-]/ui', ' ',$epAtual);
echo '<li><a href="javascript:void(0)" class="ativo">'.utf8_encode($nomeGenero).' <strong>123</strong></a></li>'.PHP_EOL;
}else{
echo '<li><a href="'.$urlBase.'/genero/'.$nomeGeneroCaracteres.'">'.utf8_encode($nomeGenero).' <strong>123</strong></a></li>'.PHP_EOL;
}
}
}
}
Goal is to leave this: animes 2 | aventura 5 | comedia 7 .....
solution
I got it the following way, it's there for whoever needs it
$generos = mysqli_query($conn,"SELECT * FROM 'generos'");
while($res = mysqli_fetch_assoc($generos)){
$nomeGenero = $res['nome_genero'];
$nomeGeneroCaracteres = $res['nome_genero'];
$generoSerie = $res['nome_genero'];
$seriadosConta = mysqli_query($conn,"SELECT COUNT(genero_serie) AS TOTAL FROM seriados WHERE genero_serie LIKE '%$generoSerie%'");
while($row = mysqli_fetch_assoc($seriadosConta)){
$gn = [rtrim(''.$nomeGenero.'',',')];
foreach ($gn as $epAtual){
@$generoAtual = $urlE[1];
if($generoAtual == $epAtual){
$epAtual = preg_replace('/[-]/ui', ' ',$epAtual);
echo '<li><a href="javascript:void(0)" class="ativo">'.utf8_encode($nomeGenero).' <strong>'.$row['TOTAL'].'</strong></a></li>'.PHP_EOL;
}else{
echo '<li><a href="'.$urlBase.'/genero/'.$nomeGeneroCaracteres.'">'.utf8_encode($nomeGenero).' <strong>'.$row['TOTAL'].'</strong></a></li>'.PHP_EOL;
}
}
} }
Source