Cakephp foreach condition -
i have show table of reservation of 3 biens should show me 3 line of 3 reservation show me 1 line in controllers
public function index_hote() { $this->reservation->recursive = 1; $this->loadmodel("bienspersonne"); if($this->session->read('auth.user.0.personne.id')){ $options = $this->bienspersonne->findbypersonneid($this->session- >read('auth.user.0.personne.id')); $this->loadmodel("personne"); $biens=$this->personne->findbyid( $options['bienspersonne']['personne_id']); foreach ($biens['bien'] $bien) { $reservations=$this->reservation- >find('all',array('conditions'=>array('reservation.idbien'=> $bien['idbien']))); debugger::dump($reservations); $this->paginate('reservation'); $this->set('reservations', $reservations); }}}
in view
<?php foreach ($reservations $reservation): ?> <tr> <td><?php echo h($reservation['reservation']['datereserdu']); ?></td> <td><?php echo h($reservation['reservation']['datereserau']); ?> </td> <td><?php echo h($reservation['reservation']['montantapaye']); ?></td> <td><?php echo h($reservation['reservation']['etatreservation']); ?> </td> </tr> <?php endforeach ?>
if doo debug resevation show me
array( (int) 0 => array( 'reservation' => array( 'idreser' => '1', 'datereserdu' => '2016-04-23', 'datereserau' => '2016-04-27', 'montantapaye' => '500', 'etatreservation' => 'attente', 'iddev' => '0', 'idbien' => '9', 'id' => '24' ), 'personne' => array( 'login' => '*****', 'id' => '24', 'designation' => 'client', 'nom' => 'mohamed', 'prenom' => 'jmaa', 'datenaiss' => '1991-07-22', 'adresse' => 'rue paris', 'telfixe' => '26119945', 'telmobile1' => '95632114', 'telmobile2' => '98745213', 'email' => 'wahibaml@gmail.com', 'mdp' => '26111991', 'lienphotopersonnel' => 'sou.jpg', 'idville' => '14' ), 'device' => array( 'iddev' => null, 'nomdev' => null, 'logodev' => null, 'coefficient' => null ), 'bien' => array( 'idbien' => '9', 'designbien' => 'maison pour couple', 'apropos' => 'grand maison', 'capaciteaccueil' => '5', 'nbsallebain' => '1', 'nbchambre' => '3', 'nblits' => '5', 'description' => 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh', 'adresse' => 'rue ladikiya', 'immeuble' => 'zitouna', 'affichable' => false, 'affichablepageaccueil' => false, 'idtypelogement' => '1', 'idville' => '1', 'idpays' => '1', 'idtypebien' => '1', 'poslat' => '36.4236', 'poslong' => '10.6088' ) ) ) array( (int) 0 => array( 'reservation' => array( 'idreser' => '3', 'datereserdu' => '2016-04-08', 'datereserau' => '2016-04-29', 'montantapaye' => '700', 'etatreservation' => 'attente', 'iddev' => '0', 'idbien' => '21', 'id' => '24' ), 'personne' => array( 'login' => '*****', 'id' => '24', 'designation' => 'client', 'nom' => 'mohamed', 'prenom' => 'jmaa', 'datenaiss' => '1991-07-22', 'adresse' => 'rue paris', 'telfixe' => '26119945', 'telmobile1' => '95632114', 'telmobile2' => '98745213', 'email' => 'wahibaml@gmail.com', 'mdp' => '26111991', 'lienphotopersonnel' => 'sou.jpg', 'idville' => '14' ), 'device' => array( 'iddev' => null, 'nomdev' => null, 'logodev' => null, 'coefficient' => null ), 'bien' => array( 'idbien' => '21', 'designbien' => 'appartement à louer', 'apropos' => ' garnd appartement', 'capaciteaccueil' => '5', 'nbsallebain' => '1', 'nbchambre' => '4', 'nblits' => '5', 'description' => 'garnd appartement', 'adresse' => 'rue syrie', 'immeuble' => 'zitouna', 'affichable' => false, 'affichablepageaccueil' => false, 'idtypelogement' => '1', 'idville' => '2', 'idpays' => '0', 'idtypebien' => '2', 'poslat' => '0', 'poslong' => '0' ) ) ) array( (int) 0 => array( 'reservation' => array( 'idreser' => '2', 'datereserdu' => '2016-04-07', 'datereserau' => '2016-04-20', 'montantapaye' => '500', 'etatreservation' => 'attente', 'iddev' => '0', 'idbien' => '22', 'id' => '24' ), 'personne' => array( 'login' => '*****', 'id' => '24', 'designation' => 'client', 'nom' => 'mohamed', 'prenom' => 'jmaa', 'datenaiss' => '1991-07-22', 'adresse' => 'rue paris', 'telfixe' => '26119945', 'telmobile1' => '95632114', 'telmobile2' => '98745213', 'email' => 'wahibaml@gmail.com', 'mdp' => '26111991', 'lienphotopersonnel' => 'sou.jpg', 'idville' => '14' ), 'device' => array( 'iddev' => null, 'nomdev' => null, 'logodev' => null, 'coefficient' => null ), 'bien' => array( 'idbien' => '22', 'designbien' => 'appartement', 'apropos' => 'grand appartement', 'capaciteaccueil' => '2', 'nbsallebain' => '1', 'nbchambre' => '2', 'nblits' => '2', 'description' => 'grand appartement', 'adresse' => 'ruen marsa', 'immeuble' => '', 'affichable' => false, 'affichablepageaccueil' => false, 'idtypelogement' => '1', 'idville' => '1', 'idpays' => '1', 'idtypebien' => '1', 'poslat' => '0', 'poslong' => '0' ) ) )
but in table show me 1 line the table plz can , mistake ?
Comments
Post a Comment