Codeigniter like post and show as likes

Asked

Viewed 50 times

1

I’m developing a publishing script, like and excuse, but when I put the option to be liked starts my mistake.

SE ( ID_PERFIL = ID_PERFIL e ID_PUBLICACAO= ID_PUBLICACAO ) { CURTIU } SE NAO { CURTIR }

But when I make this request at the bank row_array().

The result always brings the first of the list and only the first liked item appears as liked, the others do not appear because it enters the denial.

if the first is 23, he picks up 23 = 23, the second being 17, he still picks up 23 = 17 and doesn’t show up with Like.

MODEL

public function publicacao_curtida(){
$this->db->select('*, publicacao.id as id_publicacao');
$this->db->from('publicacao');
$this->db->join('user', 'user.id = publicacao.id_profile');
$this->db->join('publicacao_like', 'publicacao.id = publicacao_like.id_publicacao');
$this->db->order_by("publicacao.id DESC");
//$this->db->order_by("rand()");
//$this->db->limit(5);
$query = $this->db->get();
return $query->row_array(); }

HTML

        <?php if($this->session->userdata('user_id') == $publicacao_curtida["id_profile"] && $publicacao_curtida["id_publicacao"] == $public->id_publicacao){ ?>
            <a href="#" onclick="descurtir_postagem(<?php echo $public->id_publicacao ?>)"><i class="fa fa-thumbs-up" style="color:#0093D6;"></i> Curtiu</a>
        <?php }else{ ?> 
            <a href="#" onclick="curtir_postagem(<?php echo $public->id_publicacao ?>)"><i class="fa fa-thumbs-up" ></i> Curtir</a>
        <?php } ?>

1 answer

0


To get all results of a query use result_array() or just result() (which returns an array of objects). row_array() return only one result/row from the database.

  • Still not quite what I need... When enjoy I save in the bank that enjoyed. So I want to compare if I like that post or other. Whereas when I compare, it just appears as liked the first post. or when I create a foreach it shows how many likes have saved in the table

Browser other questions tagged

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