|
pagolina
|
can some body help me? am designing my application with php mysql. i have about 100 record in a particular table, i want to display some thing like this on a particular page
100 registered 26 female 74 male 80 member 20 pending
pls how do i get this statistic with phpmysql?
|
|
|
|
|
|
Tech Pros (m)
|
do you have any other table aside the one with the 100 records? if you dont, i think you need one more for the pending member. also you can post the application schematic, so we can have a better understand of how the application is suppose to work
|
|
|
|
|
|
yawa-ti-de (f)
|
after what tech pros has said, which is called database normalization, you will need to use the "WHERE" clause to filter and the COUNT(*) statement to get the count. So it would go something like this (of course, verify for errors):
SELECT COUNT(*) FROM table_poster WHERE status = 'registered (or whatever you call it)'
Make sense?
|
|
|
|
|
|
lojik (m)
|
//To get male and female $sql=SELECT count(*) as total, sex FROM myTable GROUP BY sex
//to get registered and pending $sql=SELECT count(*) as total, status FROM myTable GROUP BY status
//to count all members after running mysql_query mysql_num_rows($result);
|
|
|
|
|
|
*dhtml (m)
|
Impressive. You guyz are just spewing codes without seein the structure of the table. U may be surprised that the table does not contain. . .
|
|
|
|
|
|
yawa-ti-de (f)
|
dhtml, it is possible but the point of at least my code is not to provide answers based on his table structure but for the purpose of understanding where he needs to go.
The poster should be able to infer from our respective code snippets what he needs to do: 1) Get the number of rows 2) Filter the results, if applicable 3) group or order the results, if applicable.
|
|
|
|
|
|
*dhtml (m)
|
Actually all the codes are ok. what i dont know is - if the OP has gotten the table correctly laid out with the right fields before coming back here and say that our codes are not working.
|
|
|
|
|
|