The database table
First we need some database table to make our samples run.The samples below are based on the MySQL database, but feel free to adapt it to your database.
Table structure
The design of this table is very, very, poor (database admins, don't blame me!) but will be
very useful for our samples.
Create a database called phpreports (if your database allow you to create this kind of stuff),
put it in use and make a table called saleslog with fields like these:
name | type | length | decimal places |
id | numeric | 5 | |
name | char | 50 | |
city | char | 50 | |
product | char | 50 | |
value | numeric | 15 | 2 |
Table creation script
create table saleslog ( id numeric(5), name varchar(50), city varchar(50), product varchar(50), value numeric(15,2) );Now put the following values there:
1,"Eustaquio Rangel","Sao Jose do Rio Preto, SP","Book - Linux Programming",25
1,"Eustaquio Rangel","Sao Jose do Rio Preto, SP","Book - Design Patterns" ,35
2,"Ana Carolina" ,"Sao Jose do Rio Preto, SP","Book - Photoshop 7.0" ,22.50
3,"Andre Kada" ,"Sao Paulo, SP" ,"CD - Kreator - Violent Revolutions",15
Data insertion script:
insert into saleslog values (1,"Eustaquio Rangel","Sao Jose do Rio Preto, SP","Book - Linux Programming",25);insert into saleslog values (1,"Eustaquio Rangel","Sao Jose do Rio Preto, SP","Book - Design Patterns",35);
insert into saleslog values (2,"Ana Carolina" ,"Sao Jose do Rio Preto, SP","Book - Photoshop 7.0",22.5);
insert into saleslog values (3,"Andre Kada" ,"Sao Paulo, SP","CD - Kreator - Violent Revolutions",15);
Now we have something to work on.