PHP MySQL选择问题[重复]

This question already has an answer here:

i have a database called emplyees structured like this:

id name   entrydate    totalhours
1  test   11/11/2015      8
2  test2  11/11/2015      7
3  test   11/12/2015      8
4  test2  11/12/2015      9

And i want to turn it in something like this

id name 11/11/2015  11/12/2015 
1  test      8          8
2  test2     7          9

I tried several methods but no result how can i do this? Thanks in advance!

</div>

Once you fix your dates, something like this should work in PHP...

<?php

require('path/to/connection/stateme.nts');

$query = "
SELECT name
     , entrydate
     , totalhours
  FROM my_table
 ORDER
    BY name;
";

$result = mysqli_query($db,$query);

$array = array();

while($row = mysqli_fetch_assoc($result)){
$array[] = $row;
}


foreach ($array as $element)
    $newArray[$element["name"]][] = array($element["entrydate"]=>$element["totalhours"]);

print_r($newArray);

?>

outputs:

Array
(
    [test] => Array
        (
            [0] => Array
                (
                    [2015-11-11] => 8
                )

            [1] => Array
                (
                    [2015-11-12] => 8
                )

        )

    [test2] => Array
        (
            [0] => Array
                (
                    [2015-11-11] => 7
                )

            [1] => Array
                (
                    [2015-11-12] => 9
                )

        )

)

...which can easily be spat out to a table or json