Hello,
Debugging the query result gives me -

Array
(
    [0] => Array
        (
            [Hotel] => Array
                (
                    [id] => 6
                    [name] => TTT
                    [address] => Main Road9
                )

            [HotelPhoto] => Array
                (
                )

            [Room] => Array
                (
                    [0] => Array
                        (
                            [id] => 1
                            [hotel_id] => 6
                            [name] => Premium
                            [description] => asdadasasd
                            [created] => 2011-09-24 07:58:43
                            [modified] => 2011-09-24 07:58:43
                            [cost_price_sglb] => 12
                            [cost_price_twnb] => 123
                            [cost_price_trpl] => 1123
                            [extra_bed] => 123
                            [inventory] => 122
                        )

                )

        )

    [1] => Array
        (
            [Hotel] => Array
                (
                    [id] => 10
                    [name] => asd
                    [address] => dsadsad
                )

            [HotelPhoto] => Array
                (
                )

            [Room] => Array
                (
                )

        )

)



Now, I can access Hotel.id Hotel.name and Hotel.address using a
foreach loop.

foreach ($h as $hotel):
                $class = null;
                if ($i++ % 2 == 0) {
                        $class = ' class="altrow"';
                }


        ?>
        <tr<?php echo $class;?>>
                <td><?php echo $hotel['Hotel']['id']; ?>&nbsp;</td>
                <td><?php echo $hotel['Hotel']['name']; ?>&nbsp;</td>
                <td><?php echo $hotel['Hotel']['address']; ?>&nbsp;</td>

How do I make another nested loop to display Room.name etc as each
Hotel has many rooms ?

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to