-1
As I could count the repeated fields of my table, I tried so more did not work:
Hold the name of the generous
$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 so: animes 2 | aventura 5 | comedia 7 .....
hiccup
I got it this way, this one 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
my God.. this is going to waste so much server resource
while > foreach > while
??– 13dev
@13dev I need to leave the menu marked according to the page that weighs this, there is another way ?
– goio
breaks code into functions so you can reuse and take advantage of the performance of
PHP
– 13dev
@13dev I’m new, I’ve found a big step have come up to here
– goio
I didn’t question any of that, so take a look at
PDO
andorientação a objectos
, you’re gonna love it! :)– 13dev
If your goal is just to count the amount of genres, do it directly in sql and not by loops bringing your complete query.
– Luiz Pillon
@Luizpillon would be more or less like this ?
SELECT genero_serie FROM seriados
, How many fields have the same name directly in sql ? passing the value of it in the url I can count, the problem is when I don’t pass anything url– goio
I’ll send the query to Voce in the answers
– Luiz Pillon
I don’t know why they vote negative if they don’t help anything, leave it to those who want to help
– goio