Welcome Guest, Not a member yet? Register   Sign In
Help me
#1

[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
#2

[eluser]WanWizard[/eluser]
See the user guide: http://ellislab.com/codeigniter/user-gui...ecord.html
#3

[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('*');
$this->db->from('hotel');
$this->db->join('season', 'season.id = hotel.seasonid');
and so on...
#4

[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">
&lt;?php
$season = $season->result();
print_r($season);
foreach($season as $season_list)
{
?&gt;
<div>Season: &lt;?php echo $season_list->start_date; ?&gt; - &lt;?php echo
$season_list->end_date; ?&gt;</div>

<table>
<tr>
<th>Type of Accomodation</th>
<th>Base Tariff</th>
<th>Special Tariff</th>
<th>Tax</th>
<th>Reservation</th>
</tr>
&lt;?php
$special_rate = $special_rate->result();
//print_r($special_rate);
foreach($special_rate as $rate)
{
?&gt;


<tr>
<td>&lt;?php echo $rate->name; ?&gt;</td>
<td>&lt;?php echo $rate->base_tariff; ?&gt;</td>
<td>&lt;?php echo $rate->special_rate; ?&gt;</td>
<td>&lt;?php echo $rate->tax; ?&gt;</td>
<td><a >id.'/'.$rate->name.'/'.$rate->hotel_id);
?&gt;">Reserve Now</a></td>
</tr>

&lt;?php
}
?&gt;
</table>
&lt;?php
}
?&gt;
</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
#5

[eluser]karattejoseph[/eluser]
Hi all I got the solution ,I use multiple views in controller
ie, each forloop loads views




Theme © iAndrew 2016 - Forum software by © MyBB