List DATA fields per Dates

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
awaheed
Forum Newbie
Posts: 1
Joined: Mon Feb 02, 2009 8:58 am

List DATA fields per Dates

Post by awaheed »

Hi there,

I am working to create a matrix style output similar to https://secure.sgs.gov.sg/apps/fda/sgsBondsForm.jsp

Notice that after running the query, you have fields across colummn, date across rows (all calender dates) and values in (row,col) format.

Ii have a database Prices i.e.

px_history

filed_name, date, close_px

Can u help me to provide a mySQL query and any PHP processing code, where I can get prices for different fields for a date range e.g. start, end date.

Form:
------
start date :_______
end date L: ________

final output
------------
e.g. Jan 01, 2009 to Feb 01, 2009

It should print all dates b/w start and end, i.e.

Dates Field 1 Field 2
01/01/2009 close_px <empty if there is no record>
01/01/2009 close_px close_px
...
...
01/02/2009
.....

if you notice, we have FIELDS on the Columns and DATES on the Rows and DATA (close_px) on each columns for each field, It is kind of matrix.

I've trying to get this works for weeks and months, but could not found a good solution.

Any guidance will be highly appreciated..

Many Many Many Many Many Many Thanks....
Post Reply