Jump to content


Photo

Ordering Numbers


  • Please log in to reply
4 replies to this topic

#1 ssjskipp

ssjskipp
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 05 March 2006 - 05:12 AM

I've got a list of about 350+ numbers, and there' in the 700-800's, but I'd like to know how to do a ffew things:
Order them form least to greatest
AND // OR
Count how many times each number appears, and display the results.

How would I go about doing this?

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 05 March 2006 - 09:35 AM

Put them into an array.

To put them in order, [a href=\"http://www.php.net/sort\" target=\"_blank\"]http://www.php.net/sort[/a]

To count, [a href=\"http://www.php.net/array_count_values\" target=\"_blank\"]http://www.php.net/array_count_values[/a]
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 ssjskipp

ssjskipp
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 05 March 2006 - 09:29 PM

[!--quoteo(post=351783:date=Mar 5 2006, 04:35 AM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 5 2006, 04:35 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Put them into an array.

To put them in order, [a href=\"http://www.php.net/sort\" target=\"_blank\"]http://www.php.net/sort[/a]

To count, [a href=\"http://www.php.net/array_count_values\" target=\"_blank\"]http://www.php.net/array_count_values[/a]
[/quote]

thank you =]

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,016 posts

Posted 05 March 2006 - 09:40 PM

Are your 350+ numbers in a database table?
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 ssjskipp

ssjskipp
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 05 March 2006 - 09:53 PM

[!--quoteo(post=351891:date=Mar 5 2006, 04:40 PM:name=Barand)--][div class=\'quotetop\']QUOTE(Barand @ Mar 5 2006, 04:40 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Are your 350+ numbers in a database table?
[/quote]

Sadly, no =[!
But I got them sorted and counted, thanks =]

If they were in the database, I'd do something like
SELECT * FROM `table` ORDER BY `num` ASC
or something....




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users