By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,932 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,932 IT Pros & Developers. It's quick & easy.

how to do sort / mixing in php

P: 8
i want to know how to do sort using php,

for example,

$table = mysql_query("SELECT * FROM ... ");

while ($... = mysql_fetch_array($table)

the result will show like this :

data1
data8
data7
data2
data1
data8
data7
data2
data1
data8
data1
data8
data7
data2
data1
data8

but i want to know how to make the result show like this :
data1 (14)
data2 (10)
data7 (5)
data8 (19)

Thanks in advance to all for any info.
Apr 14 '10 #1

✓ answered by code green

Expand|Select|Wrap|Line Numbers
  1. SELECT datafield, COUNT(datafield) GROUP BY datafield

Share this Question
Share on Google+
2 Replies


code green
Expert 100+
P: 1,726
Expand|Select|Wrap|Line Numbers
  1. SELECT datafield, COUNT(datafield) GROUP BY datafield
Apr 14 '10 #2

P: 8
useful reply
thanks code green u really an Expert
Apr 15 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.