I am a beginner in PHP and I am making a system where the user can register and register and make postings, it is a blog system. I mounted the user with SESSION and I can only display his data. In my database I have the users table, where your data and table posts remain. What I want to know now is how I can list in the user profile, only the posts he made, because the way I have done so far, when I display the posts appear the posts of all registered users. Here is my code and thanks to those who help.
My table where I display the list of posts
<table>
<?php
$postagens = listaPostagens($conexao);
foreach($postagens as $postagem) {
?>
<tr>
<td>
<img src="envios/<?=$postagem['img']?>"/>
</td>
<td>
</span><?=$postagem['localizacao']?>
</td>
<td>
<?=$postagem['texto']?>
</td>
<td>
<?=$postagem['visualizacoes']?>
</td>
<td>
<?=$postagem['curtidas']?>
</td>
<td>
<?=$postagem['compartilhamentos']?>
</td>
</tr>
<?php
}
?>
</table>
</section>
<?php
Function that lists posts:
function listaPostagens($conexao) {
$postagens = [];
$query = mysqli_query($conexao, "select * from postagens");
while($postagem = mysqli_fetch_assoc($query)) {
array_push($postagens, $postagem);
}
return $postagens;
}
As I said, this way I'm selecting posts from all users and need help to list the posts only from the currently logged-in user.