Php Record Counter

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 08, 2009, 11:46 AM
423573 members and 291125 Topics
Latest Member: Daniellink
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: OmniPotens, yawa-ti-de)  |  Php Record Counter
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Php Record Counter  (Read 45 views)
pagolina
Php Record Counter
« on: June 26, 2009, 03:26 PM »

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)
Re: Php Record Counter
« #1 on: June 26, 2009, 04:21 PM »

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)
Re: Php Record Counter
« #2 on: June 26, 2009, 07:54 PM »

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)
Re: Php Record Counter
« #3 on: June 29, 2009, 03:28 PM »

//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)
Re: Php Record Counter
« #4 on: June 29, 2009, 07:44 PM »

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)
Re: Php Record Counter
« #5 on: June 29, 2009, 09:13 PM »

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)
Re: Php Record Counter
« #6 on: June 30, 2009, 03:39 AM »

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.
 The Web/webmasters As Agents Of Social Change  Qgroup4u.com Test, Learn, Study & Speak The English Language Online  Windows 7 Is Made To Boost Ie & Cripple Other Browsers  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.