Welcome Guest, Not a member yet? Register   Sign In
View that prints all the array $data['personas'] in a table html.
#3

(04-20-2017, 08:10 PM)JayAdra Wrote: You can use the array_keys function to get the keys of the first item (if they all have the same keys?) and loop through them to create the header row.

Then simply loop through the data array and print the data.

Hello Jay.

Thanks for your answer.



1) Referent to array_keys

I tried this in the View:

Code:
         <div class="page-header">
 
        <Table border="1">
            <?php foreach($personas as $p){ ?>
                <tr><td><?php echo $p->USER_ID; ?></td></tr>
            <?php }//end foreach ?>
        </Table>
        </br>
        </br>
         <pre><?php print_r(array_keys($personas)) ?> </pre>

And it prints the first level of keys:

[Image: 20170421044653.jpg]
I don't know how descend levels of sub Arrays...

Do you know how?


2) Referent to simply loop through the data array and print the data.

I don't know how print a sub Array without the name of the Fields. I only know like here:

Code:
        <Table border="1">
            <?php foreach($personas as $p){ ?>
                <tr><td><?php echo $p->USER_ID; ?></td></tr>
            <?php }//end foreach ?>
        </Table>

I tried this but not rules:

Code:
        <Table border="1">
            <?php foreach($personas as $p){ ?>
                <tr><td><?php echo $p->[0]; ?></td></tr>
            <?php }//end foreach ?>
        </Table>

Confused


Thanks a lot...
Reply


Messages In This Thread
RE: View that prints all the array $data['personas'] in a table html. - by Angel_Debat - 04-21-2017, 02:55 AM



Theme © iAndrew 2016 - Forum software by © MyBB