I’m not an expert in PHP even though I’ve been working with some stuff, copying and pasting from here and there, well I want to ask something that I can not find and that I don’t have the slightest idea on how to implement it.
For instance, at a table like this:
+------+-----+
|NAME |BIRTH|
+------+-----+
|John |1980 |
|Carl |1982 |
|Alice |1990 |
|June |1994 |
|Rob |1998 |
|Alice |1998 |
|John |2000 |
|Alice |2001 |
|Etc. | |
+------+-----+
I do different queries, like these below (and I could keep doing queries with any combination of years):
Select * from table where BIRTH between 1980 and 1990Select * from table where BIRTH between 1980 and 2001Select * from table where BIRTH between 1990 and 2001
So I will get 3 different tables, and from those tables I need to count the different contents,
for instance, from the table obtained with the query1 I need to obtain:
John = 1
Carl = 1
Alice = 1
from table of query2:
John = 2
Carl = 1
Alice = 3
June = 1
Rob =1
from table of query3:
Alice = 3
John = 1
Carl = 1
June = 1
Rob =1
And remember the big table has 700 records, so it could appear any new name, and I need to print out the result in the same way:
Alice = 3
John = 1
NewName = 1
June = 1
Rob =1
My final goal is do percentages in relation to the obtained table, and not to the total of registers.
You should do it in SQL, not in PHP :
This will produce the exact view you want. Names as first column, the count on the second.