Accessing records from 2 tables in a single view |
[eluser]shailendra[/eluser]
I have controller dashboard.php which to fetch data from "bids" and "projects" table and display records from both the tables into dashboard_view.php. But in dashboard_view.php I get records from only "projects" table. How do I get records from 2 tables without using join?? The code for dashboard.php is Code: <?php and the code for dashboard_view.php is Code: <table width="95%" border="0" align="center" cellpadding="4" cellspacing="0" class="user1_inner">
[eluser]Seb[/eluser]
There is more than one way to do it, but your same dashboard view is called twice with the two datasets. Try this instead: Code: <?php and this for the view: Code: <table width="95%" border="0" align="center" cellpadding="4" cellspacing="0" class="user1_inner">
[eluser]shailendra[/eluser]
Thanks mate for your help.......It worked with your code.
[eluser]shailendra[/eluser]
With reference to above code, I wanted to echo no. of records so I wrote this code Code: function index() How do I count no. of records?
[eluser]bEz[/eluser]
http://ellislab.com/codeigniter/user-gui...ecord.html Don't take this as an insult, but certain questions like this are in the User Guide. There are questions which are a bit trivial, but not something like this.
[eluser]adityamenon[/eluser]
Code: $data['projects']= $this->db->where('user_id', 1)->get('projects')->num_rows();
[eluser]shailendra[/eluser]
I'm not feeling offended........but I read this page on user guide....but could not find a solution.....also read CI forums...got "count_all" but it didnt help as it does does not work with "where" clause. But I found solution myself Code: echo count($projects); My question to you is - below line of code works in the Blog tutorial.Why doesn't it work in this case? Code: echo $projects->num_rows();
[eluser]shailendra[/eluser]
This line of code worked too. Thanks. Code: $data['projects']= $this->db->where('user_id', 1)->get('projects')->num_rows();
[eluser]adityamenon[/eluser]
[quote author="shailendra" date="1309002169"]This line of code worked too. Thanks. Code: $data['projects']= $this->db->where('user_id', 1)->get('projects')->num_rows(); cheers. |
Welcome Guest, Not a member yet? Register Sign In |