-1
My blog is showing the post normally, minus the category part. I don’t know what else to do to fix this problem. Could someone please give me a little push?
$resultado = mysql_query($consulta, $conn) or die(mysqli_error());
$linhas = mysql_fetch_assoc($resultado);
Below shows part of the code:
<?php do { ?>
<div class="post post-row">
<a class="post-img" href="blog-post.html"><img src="Admin/app/webroot/files/post/imagem1/<?php echo $linhas['imagem1_dir']; ?>/<?php echo $linhas['imagem1']; ?>"></a>
<div class="post-body">
<div class="post-meta">
<a class="post-category" href="category.html"><?php echo $linhas['categoria']; ?></a>
<span class="post-date"><?php echo utf8_encode($linhas['data']); ?></span>
</div>
<h3 class="post-title"><a href="blog-post.html"><?php echo utf8_encode($linhas['titulo_principal']); ?></a></h3>
<p><?php echo utf8_encode($linhas['texto_inicial']); ?></p>
</div>
</div>
<?php } while ($linhas = mysql_fetch_assoc($resultado)); ?>
</div>
But only this part does not show, that it is precisely the category:
<a class="post-category" href="category.html"><?php echo $linhas['categoria']; ?></a>
I have two tables in the database, a call Posts that has categoria_id. Already the table Categories, has id and category. Someone who can help me? Thank you!
Please show the query sql in the database.
– Bruno
I think this is the part: $query = "SELECT * FROM posts ORDER BY id DESC"; Sorry if I’m wrong, I’m still studying mysql. When do I put 'categoria_id' (where you only have category) <?php echo $lines['category']; ? > appears the right ids, but the category name does not show.
– Márcia Prates
If you want to display data from the two tables then you will have to do an INNER JOIN between the two tables through the category id field common to both tables.
– anonimo