0

i have a database consists of4 fields for example:

name    date        Description      Amount 

Ali    05/04/2012   Salaries         2000$
Ali    08/04/2012   commission        100$
ALi    11/04/2012   Transport         100$
Ali    05/05/2012   Salaries         2000$
Ali    08/05/2012   commission        100$
ALi    11/05/2012   Transport         100$

in case i need to retrieve information and inquiries about the salary page , for Ali Only i need the statement of each month to be separately by separate line and sum of the total amount during that month

i need to know how to do this in mysql PHP Script .

Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207

1 Answers1

0

while this does not relate to your question, but to correct you.

i have a database consists of4 fields for example:

you are referring the table as database. please correct it. it is not database as a whole but a table within a database.

you are missing primary keys in your table

it is always good to have a primary key for each and every table, mainly because primary key uniquely identifies each row in the table. here is good explanation on why you should always use primary keys in your table Should each and every table have a primary key?

2000$

you don't need a dollar symbol at the end of integer value. since the database does not have any special meaning for that symbol, and by using this you will loose the ability of some calculation that database could have performed for you. since 2000$ is not same as 2000 if you want database to perform the calculation store only integers. if you want to store the symbol too then you can store it in another column.

Community
  • 1
  • 1
Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207
  • what i added in my question is just the result which you should see in the database , i need the code which does what i mentioned which is to get me the result which is above separated for each month in clear bold line or color line or what ever to make is show that each motnh shows in different line and with sum of whole amount in each month for each person i search for . i need a code which gives me the result as what i mentioned only . – Mohammed Alshaer May 15 '12 at 14:53