Reply to Re: save array data into vars

Your name:

Reply:


Posted by a on 11/10/11 11:16

Irlan agous wrote:
> Hello i get the information out of one field named persid. Now i get a list
> of all the persid's like 2,2,3,4,4,4,5. I want to select the maximun
> existing values, the second maximum etc. For example in this care number 4
> had the highest rank(with 3 times), second is 2 (with 2 times) etc. But how
> can i save distinct numbers and its amount to a variable? becouse then im
> able to check which one is the maximum etc, thanks for the help
>
> $query = "select persid from reactie";
> $result = mysql_query("SELECT persid FROM reactie");
>
> while ($array = mysql_fetch_array($result);){
> echo "The name is " . $array[persid];
> }
>
> Irlan
>
>

SELECT persid, count( persid ) AS cnt
FROM reactie
GROUP BY persid
ORDER BY cnt DESC

Cheers,
Nikolaj

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация