How can I make and show associative table ?
Posted: Mon Apr 20, 2009 3:21 pm
I will create loop to add data to associative table but first I would like to make it manually because it is complicate for me.
Did I make this associative table correct ? How can I show data from this table using for example loop foreach ? It should look:
employees:
- Jack Jones......
- Jane Munson....
students:
- Jack Jones2......
- Jane Munson2....
Did I make this associative table correct ? How can I show data from this table using for example loop foreach ? It should look:
employees:
- Jack Jones......
- Jane Munson....
students:
- Jack Jones2......
- Jane Munson2....
Code: Select all
//add first data to table:
$data[][][][] = array(
array(
'employees'=>array(
array('name' => 'Jack Jones', 'home' => '777-555-5555',
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
array('name' => 'Jane Munson', 'home' => '000-555-5555',
'cell' => '123456', 'email' => 'jane@myexample.com'),
),
)
);
//add second data to table:
$data[][][][] = array(
array(
'students'=>array(
array('name' => 'Jack Jones2', 'home' => '777-555-5555',
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
array('name' => 'Jane Munson2', 'home' => '000-555-5555',
'cell' => '123456', 'email' => 'jane@myexample.com')
),
)
);