Hi,
Im totally new to php and need some help please.
I have a mssql table with the following data
Name Amount Month
------- ---------- --------
John 500.00 10/2005
Jack 600.00 11/2005
The result Im trying to get using php is :-
Name 10/2005 11/2005
------- ---------- -----------
John 500.00
Jack 600.00
I am total stupped I can get the column headings but I can't seem to get the amounts in the correct columns. Could some please point me in the write direct as my code now looks a complete mess with for,while etc.......
any help would be much appreciated
Thx.
Dispaly crosstab
Moderator: General Moderators
- jayshields
- DevNet Resident
- Posts: 1912
- Joined: Mon Aug 22, 2005 12:11 pm
- Location: Leeds/Manchester, England
Code: Select all
<?php
$result = mysql_query('SELECT * FROM table');
$data = array();
$i = 0;
while ($row = mysql_fetch_assoc($result)) {
$data[$i]['name'] = $row['name'];
$data[$i][$row['month']] = $row['amount'];
$i++;
}
print_r($data);
?>