Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to display the total number of same text entries from a table (php)?

New Here ,
Apr 30, 2012 Apr 30, 2012

Hello,

I have a database "choir" with the table "members" which has the following data structure:

NameVoice
Jennasoprano
Dannaalto
Roxyalto
Damientenor
Carmenalto
Daisysoprano

Diana

alto
Roberttenor
Johnbass

With Dreamweaver php, any help me on how can I display in a webpage the total number of "alto", in this case: 4.

Thanks,

Luci.

TOPICS
Server side applications
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 30, 2012 Apr 30, 2012

SELECT voice, COUNT(*) as voice FROM choir GROUP BY voice ORDER BY voice DESC;

This will give you plain voiceid - count

SELECT voice, COUNT(*) as name FROM choir GROUP BY voice ORDER BY voice DESC;

This will give you name - voice - count

Trust it helps.

Cheers,

ST

Translate
LEGEND ,
Apr 30, 2012 Apr 30, 2012

Create a new Recordset in Dreamweaver and run the following SQL:

SELECT voice, count(voice) AS voiceCount FROM choir GROUP BY voice
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2012 Apr 30, 2012

Hi,

Thanks for your fast reply. I've used your proposal and it works fine.

However, I get only the value 4.

What I would like is:

alto 4

bass 1

soprano 2

tenor 2

Any help on how can I achieve this?

Thank you very much?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 30, 2012 Apr 30, 2012

SELECT voice, COUNT(*) as voice FROM choir GROUP BY voice ORDER BY voice DESC;

This will give you plain voiceid - count

SELECT voice, COUNT(*) as name FROM choir GROUP BY voice ORDER BY voice DESC;

This will give you name - voice - count

Trust it helps.

Cheers,

ST

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 30, 2012 Apr 30, 2012
LATEST

Thank you very much. This is what I wanted.

I have also another harder request. I've put it separately.

If you could help me on that too, I would be higly appreciating.

Thanks!

http://forums.adobe.com/thread/997110?tstart=0

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines