views:

238

answers:

2

Hi,

I am trying to display a multidimensional array into html table using php nd mysql.

The array structure is like below

Array
(
    [az] => Array
        (
            [0] => Array
                (
                    [work] => dsdsds
                    [time] => 2:47---2:55
                    [total] => 8
                )

        )

    [an] => Array
        (
            [0] => Array
                (
                    [work] => sdsdsdsdsd
                    [time] => 1:47---2:47
                    [total] => 60
                )

        )

    [mu] => Array
        (
            [0] => Array
                (
                    [work] => sdsdsd
                    [time] => 1:30---2:48
                    [total] => 78
                )

        )

    [raj] => Array
        (
            [0] => Array
                (
                    [work] => dsdwew
                    [time] => 3:34---3:40
                    [total] => 6
                )

            [1] => Array
                (
                    [work] => cdsfdfdfd
                    [time] => 3:25---3:35
                    [total] => 10
                )

        )

)

it will go through columns first and then it will come to rows like this

user1   user2   user3
aa      bb      cc

Plz suggest..

+1  A: 

U should read about foreach.

http://php.net/manual/en/control-structures.foreach.php

And I think that inserting this values into table won't be any problem.

oneat
A: 

If i understand your question write that's what y need

    foreach($array as $tr=>$trData)
    {
      echo "<tr>{$trData["which field you want to display"]}</tr>";

      echo "<tr>";
      foreach($tdData as $td=>$tdData)
      {
         echo "<td>{$tdData["which field you want to display"]}</td>";
      }
    echo "</tr>";
    }
ntan