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

I have this table

I want to get this result



Workers amount will go to column in relevant data

Group by code.

I wrote this query


$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)){ 

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.