Sir I want to generate a query which will convert data from rows to columns

I have this table
aa.png

I want to get this result

bb.png

[IMG]http://i66.tinypic.com/2hfjep4.png[/IMG]

Workers amount will go to column in relevant data

Group by code.

I wrote this query

session_start(); 
require_once("includes/connectw.php"); 

$query = "select date,code,worker,sum(amount)as amount from sales group by date,code" ; 
$result = mysqli_query($con,$query)or die ("Error". mysqli_error($con)) ;   
while ($row = mysqli_fetch_array ($result)){ 
    echo($row['date'])."-"; 
    echo($row['code'])."-"; 
    echo($row['worker'])."-"; 
    echo($row['amount'])."<br>"; 
}  

The query show following result

Click Here

But do not know how to display rows data into columns.

Please help

OK, I read this a few times and can guess the query is in PHP. But to get that table output you have to reveal how you will view the result. It might be this is the backend of a server and the viewer is a browser, but that's not told.

ASCII text would not normally have the needed lines and colors. Maybe a few decades ago you could use ANSI on a terminal but that's very rare.

I think you need to complete the picture. That is, reveal what's viewing this ouput.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.