Welcome Guest, Not a member yet? Register   Sign In
Throwing multiple rows, selected from the DB in one variable.
#1

[eluser]Milo[/eluser]
I am new to codeIgniter, and for some reason I cannot wrap my head around this problem. I want to make a variable that I can echo within the view, and pull multiple rows from a table that I have from one column.

so for example:

My table:

user_id file_id firstname

2 1 john smith
2 2 john smith
2 3 john smith
2 4 john smith
2 5 john smith


how can I throw the file_id's into one variable and call all of them from my table, and then put a limit on how many I want to pull. Then use the variable to echo them in the view.

Thank you guys for all your help in advance!
#2

[eluser]Stefan Hueg[/eluser]
Code:
$result = $this->db->select('*')
->from('my_table')
->where_in('file_id', array(1,2,3,4,5))
->limit(...)
->get();

Is that the solution you were asking for?




Theme © iAndrew 2016 - Forum software by © MyBB