I have a problem. I need to create a page that lists all the records with the selected category.
Code where the person selects the category and when clicking, sends to the page. (This code is working fine, just put it for better understanding.)
<h2 class="titulos">Categorias</h2>
<div class="cat-lista list-group">
<?php
$contador = mysql_query("SELECT DISTINCT categoria, count(id) as catqtde FROM postagens group by categoria");
while($prod = mysql_fetch_array($contador)) {
?>
<a href="categoria.php" name="categoria">
<?php echo $prod['categoria']; ?>
<span class="badge bt-span badge-pill"><?php echo $prod['catqtde']; ?></span>
</a>
<?php } ?>
</div>
Code of the page that should list data with that category.
<?php
$ident = $_GET['categoria'];
$sqlstring = "SELECT * from postagens where categoria = $ident order by id DESC ";
$query = @mysqli_query($mysql->con, $sqlstring);
while ($dados = @mysqli_fetch_array($query)){
setlocale(LC_TIME,'pt_BR','pt_BR.utf-8','portuguese');
date_default_timezone_set('America/Sao_Paulo');
$datinha = date('d/m/Y', strtotime($dados['agendado']));
?>
<div class="col-lg-3 col-md-6 col-sm-12 col-all-post" >
<div class="card post-item shadow">
<a href="postagem.php?id=<?php echo $dados['id'] ?>&<?php echo slug($dados['titulo']) ?>"><img class="card-img-top post-item-img" src="<?="admin/img/".$dados['foto']?>"></a>
<div class="card-body">
<div class="d-flex justify-content-between">
<div class="categoria-span cat-span-post">
<a href="#"><span><?=$dados['categoria']?></span></a>
</div><!--categoria-span-->
<div class="info-span-blog">
<span><img src="assets/img/icon-cal.png"><?= $datinha ?> </span>
</div><!--info-span-->
</div>
<a href="postagem/<?php echo $dados['id'] ?>/<?php echo slug($dados['titulo']) ?>"><h4 class="card-title d-flex align-items-end"><?=$dados['titulo'];?></h4></a>
<a href="postagem/<?php echo $dados['id'] ?>/<?php echo slug($dados['titulo']) ?>"><h5 class="card-title"><?=$dados['subtitulo']?></h5></a>
</div><!--card-body-->
</div><!--card-->
</div><!--col-lg-->
<?php
}
$mysql->fechar();
?>
</div>
The error that appears to me is this:
Notice: Undefined index: category in D: \ Files \ USBWebserver 2 \ root \ site \ category.php on line 10