Help me |
[eluser]karattejoseph[/eluser]
I have three tables hotel,season,special_rate. The table season contains hotel id and special_rate contains season id. I have hotel id ,I want to get the details from season and different special_rates details . In normal PHP it is quiet easily, how can it done in codeIgniter
[eluser]WanWizard[/eluser]
See the user guide: http://ellislab.com/codeigniter/user-gui...ecord.html
[eluser]Dennis Rasmussen[/eluser]
CodeIgniter IS PHP. So it's the same thing you have to do. If you want to use ActiveRecord by CodeIgniter: Code: $this->db->select('*');
[eluser]karattejoseph[/eluser]
Thanks for all replays My controler is $data['season'] = $this->keralavacation_model->getSeasonDetails($id); $season=$data['season']->result(); foreach($season as $season_list) { $data['special_rate']=$this->keralavacation_model->getRate($season_list->id); } $this->load->view('keralavacation/book_now',$data); My model is function getSeasonDetails($id) { $date =date('Y-m-d'); $this->db->select('season.*'); $this->db->from('season'); $this->db->where('season.hotel_id',$id); $this->db->where('season.end_date > ',$date); $query = $this->db->get(); return $query; } function getRate($id) { $this->db->select('special_rate.special_rate,rooms.*'); $this->db->from('special_rate'); $this->db->join('rooms', 'special_rate.room_id = rooms.id ' ,'join'); $this->db->where('special_rate.season_id',$id); $query = $this->db->get(); return $query; } my view is <div id="register-body"> <?php $season = $season->result(); print_r($season); foreach($season as $season_list) { ?> <div>Season: <?php echo $season_list->start_date; ?> - <?php echo $season_list->end_date; ?></div> <table> <tr> <th>Type of Accomodation</th> <th>Base Tariff</th> <th>Special Tariff</th> <th>Tax</th> <th>Reservation</th> </tr> <?php $special_rate = $special_rate->result(); //print_r($special_rate); foreach($special_rate as $rate) { ?> <tr> <td><?php echo $rate->name; ?></td> <td><?php echo $rate->base_tariff; ?></td> <td><?php echo $rate->special_rate; ?></td> <td><?php echo $rate->tax; ?></td> <td><a >id.'/'.$rate->name.'/'.$rate->hotel_id); ?>">Reserve Now</a></td> </tr> <?php } ?> </table> <?php } ?> </div> I get first data from season and last data from special rate,then get second data from season and an error report Fatal error: Call to a member function result() on a non-object in C:\Project\thekeralavacation.com\system\application\views\keralavacation\book_now.php on line 140
[eluser]karattejoseph[/eluser]
Hi all I got the solution ,I use multiple views in controller ie, each forloop loads views |
Welcome Guest, Not a member yet? Register Sign In |