Max numbers... ordering... etc.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Max numbers... ordering... etc.

Post by Mightywayne »

So here's what I've got.

There's 10 rows: news1, news2, news3..news10. Each of them has an ID in it, and that ID represents the piece of news in another table. (they have the same IDs, long story)

So the way I update is weird, but what matters here is the solution.

My values for the news entries will be like,

news1 = 10, news2 = 14, news3 = 30

And what I need to do, is take all of those entries, and find which is the lowest of them all, and replace it.

Basically, I just need a way to find those 10 values, and find which is lowest of them. How do I do it?
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Put them into an array and sort them.
User avatar
jimthunderbird
Forum Contributor
Posts: 147
Joined: Tue Jul 04, 2006 3:59 am
Location: San Francisco, CA

Post by jimthunderbird »

Maybe use "select {your_news_value_field_name} from {$your_news_table_name} order by {your_news_value_field_name} limt 0,10";

With my best,
Jim
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

SELECT Min(ID) From tablename
see http://www.w3schools.com/sql/func_min.asp
Mightywayne
Forum Contributor
Posts: 237
Joined: Sat Dec 09, 2006 6:46 am

Post by Mightywayne »

Ah, all've you've been useful. Thank ya kindly.
Post Reply