bring data from the database according to other data registered

Asked

Viewed 101 times

0

I have a code that brings the database data and generates a table. This data is coming all that are registered, but I need only data with the same user status come.

For example: I have a user from Santa Catarina, I need to get the database data only those from Santa Catarina.

My code is in Codeigniter, and in the Model that brings this information this way:

 $this->datatables->select('lau.l_id, lau.l_tipo, emp.e_nome, lau.l_d_h, usr.usr_nome, lau.l_status');
                $this->datatables->from('lau');
                $this->datatables->join('usr', 'lau.u._id = usr.u._id');
                $this->datatables->join('disp', 'lau.d_id = disp.d_id');
                $this->datatables->join('emp', 'emp.e_id = usr.e_id');
                return $this->datatables->generate();
    }
  • And what is the result of this code?

  • You will need to use WHERE ($this->Where('state', 'SC'); to filter the results

  • @Andrébaill his code worked in parts: the part that worked was the most important part that is to pick up only the SC reports. However, I need to make him take the reports according to the status that the user registered. If he is from São Paulo, you need to get all the reports from São Paulo

  • Got it, but you can make a group by state, and bring new results through a foreach()

  • @Andrébaill as it is with datatables, I tried to do group by earlier, but it doesn’t work. I’m not sure why, since I took this code just to modify.

  • I’ve never used datatables... but it generates a table, right? What result does it bring?

  • @Andrébaill generates a table that by clicking on its columns you sort the data differently. The results you choose, in the case of this table it brings results of all reports I have registered in the bank, but I only need reports that have the same status registered in my user profile.

  • I’ve already researched this.. I understand perfectly, so you’ll have to bring the results by LEFT JOIN, the way it is up there.. passing the WHERE also.. what generated you results? What is incorrect?

Show 4 more comments
No answers

Browser other questions tagged

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