Tuesday, June 26, 2012

Re: Passing each record of array to other view

If you set separate variables, how will you write the code for the
view without knowing how many variables have been set? Better to pass
the entire array to the view and run a foreach() loop in the view.

On Tue, Jun 26, 2012 at 5:43 AM, Roshan <regmiroshan@gmail.com> wrote:
> Hi I have received the following array as a result of var_dump($x).
>
> array(2) {
>             [0]=> array(1)
>                 { ["Driver"]=> array(13)
>                     { ["driver_id"]=> string(1) "4" ["fname"]=> string(13)
> "jack williams"
>                       ["gender"]=> string(4) "male" ["email"]=> string(12)
> "jack@msn.com"
>                       ["state"]=> string(7) "florida" ["city"]=> string(17)
> "Altamonte Springs"
>                       ["zipcode"]=> string(6) "451456" ["address"]=>
> string(14) "st xena street"
>                       ["phone_no"]=> string(9) "984568745" ["car_type"]=>
> string(6) "Luxury"
>                       ["hourly_rate"]=> string(2) "45" ["occasion"]=>
> string(8) "marriage"
>                       ["driver_image"]=> string(0) ""
>                     }
>                 }
>             [1]=> array(1)
>                 { ["Driver"]=> array(13)
>                     { ["driver_id"]=> string(1) "5" ["fname"]=> string(14)
> "Peter Gonzalez"
>                       ["gender"]=> string(4) "male" ["email"]=> string(15)
> "peter@gmail.com"
>                       ["state"]=> string(7) "Florida" ["city"]=> string(17)
> "Altamonte Springs"
>                       ["zipcode"]=> string(6) "451456" ["address"]=>
> string(22) "626 Kennedy St Jackson"
>                       ["phone_no"]=> string(14) "(941) 866-0530"
> ["car_type"]=> string(6) "Luxury"
>                       ["hourly_rate"]=> string(2) "41" ["occasion"]=>
> string(8) "marriage"
>                       ["driver_image"]=> string(0) ""
>                     }
>                 }
>          }
>
> Now I want to pass each record one by one to 'view2.ctp'.
> Anybody can explain me?
>
> --
> 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
> cake-php+unsubscribe@googlegroups.com For more options, visit this group at
> http://groups.google.com/group/cake-php

--
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
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

No comments: