Welcome Guest, Not a member yet? Register   Sign In
can run mysql query again in View
#1

[eluser]xico[/eluser]
Hi all

I am developing one app using CI.I am doing well,but now I am on the stage where I need to run mysql query under loop in VIEW file.
I have written a search query where I can't join any other table. this query returns me a array of data. I have passed this array into VIEW. this data contains ID which values are in another table. so can i write a query in VIEW?
for example
Code:
for($i=0;$i<count($data);$i++)
{
   $cid = $data[$i]['id'];

}

Now with the use of $cid value I need to fetch username from another table. so how can I get it on VIEW.

Please Guide.

Thanks
#2

[eluser]alaa007[/eluser]
for sure you can run a SQL query in the view, but this way you will break the rulesof the MVC Big Grin who cares!
Why dont you create a new controller that get your request from that view and make the join and display the results in a new view?
#3

[eluser]narkaT[/eluser]
you could iterate through the results in the controler? Smile




Theme © iAndrew 2016 - Forum software by © MyBB