What about people, blz? I have 3 SQL Tables, one student call, another call collaborator and another one of posts
In the students table we have:
id
nome;
img;
email;
pass;
end;
status
matricula
dash
...
In the collaborated table we have:
id
nome
img
email
pass
end
status
codigo
And in the post table we have:
id
id_user (id do usuário q postou a publicação)
publicacao
img
date
My problem is this, I have a connection to the posting table :
<?php
$sqlPublic = "SELECT * FROM postagem ORDER BY id DESC";
$resultPublic = mysqli_query($conn, $sqlPublic);
?>
And I have While
to display all posts like this:
<?php while ($public = mysqli_fetch_array($resultPublic)) { ?>
<div class="publicacao">
div class="headerPost">
<?php
$id_Post = $public['id']; //A partir daqui pega os dados da publicação do $public que está sendo feita no while com array;
$id_user = $public['id_user'];
$postagem = $public['postagem'];
$datePost = $public['datePost'];
$sqlPostUser = "SELECT * FROM alunos WHERE id = '$id_user'"; // Aqui eu faço a conexão com a tabela alunos com sql_assoc para associar cada publicação com o usuário que à postou com referência no ID do usuário, com o id cadastrado na publicação.
$queryPostUser = mysqli_query($conn, $sqlPostUser);
$linhaAssoc = mysqli_fetch_assoc($queryPostUser);
$dasheres = $linhaAssoc['dash'];
?>
<div class="arPer">
<div class="perfilPost">
<div class="perfilFoto">
<img src="../arquivs/perfil/<?php echo $linhaAssoc['img']; ?>" />
</div>
<a href=""><h1><?php
$linhaNameAssoc = $linhaAssoc['name_user'];
$linhaNameAssoc = explode(" ", $linhaNameAssoc);
echo $linhaNameAssoc[0]." ".$linhaNameAssoc[1];
?></h1></a>
</div>
</div>
</div>
O restante do código é apenas a estrutura normal...
The problem is this: I can list with while
all the publications, so far, beauty, only, as you can see, it only has reference to the student table, and I also need to do with the contributor table , so if a contributor posts the form as it is, their data will not appear, and it will give error in the display, I tried to make the selection of the two tables ( students & collaborator ), but could not, tried using UNION
but could not, tried with JOIN
, but in that case it does not serve , I had almost the same problem with the list of users, but I managed to solve it, this is still a bit more complicated, please, who can help me answer there, I wanted to make the selection of the two tables to be able to correctly display the publications. I'm going to try something that comes to mind now, but just test it out.
I'm sorry for the size of this, it was to be clear what's happening.