Bring data without repeating id

Asked

Viewed 69 times

0

I have a table with the name of Posts table, I have a table with the name of Users table, I have a table with the name of Relations table. Now what happens is that this Relations table works as follows: The Host user goes to the site and creates a post and the freenlancer user goes there in this post where the host created and clicks to submit a proposal. The Relations table receives this user’s id, the post id, and also the post owner id. So we create a relationship between the freenlancer and the host. My problem is that if the post receives two proposals the post id if suddenly. I would like to not repeat the same post, leaving the proposals of freenlacers one below the other. Aqui um exemplo

public function getRequisicoes() 
{   
    $array = array();

    $id_user = $_SESSION['user'];

    $sql = "SELECT

    user.*, 

    relations.*, 

    post.*, post.url as main_image

    FROM relations 

    LEFT JOIN users as user ON user.id = relations.id_user_from

    LEFT JOIN posts_pl as post ON post.id = relations.id_post

    WHERE relations.id_post IN (post.id) AND relations.id_user_to = $id_user AND relations.status = '0' ORDER BY post.id";

    $sql = $this->db->query($sql);



    if($sql->rowCount() > 0) {

        foreach ($sql->fetchAll() as $value) {
  • could post your full code, please?

  • Opa Gabriel, this is my model Relations, link, in case you need more details just say.

  • I did not understand very well your doubt, you would like to leave only 1 frame of the widget on the left (photo - 41 - my second description any) and make a loop in the proposals?

  • Hi Gabriel, that’s right.

  • use the first matrix element to print the static data and the rest put inside the loop

  • Opa Gabriel, I’ve tried this way separating the loops, but it does not relate to the post. It is the post on the left and the freelancers on the right. Only when you have another post the freelancer remain in the first. I’ll send you a print so you understand better.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.