954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

arrange values from row of database in php from max to min, from min to max and value

Hi,
I've these values:
a) < 100 000 = 5 points
b) 100 000 - 250 000 = 4 points
c) > 250 000 = 3 points

$a = 140000;
$b = 23;

if ($a > 250000)
{
  $b = 3;
  echo $b;
}

if ( 100000 < $a <= 250000)
 {
   $b = 4;
   echo $b;
 }
 
if ($a < 100000)
 {
   $b = 5;
   echo $b;
 }


the logic wrong here??????????????
if i put echo $b outside of the if at the end of all the above if, does it store the value to $b.

How to sort integer value from database,
example column values from maximum to minimum and the other way around?
I know how to find max or min value. and how to nicely put it in table so that it looks this way:

Item id item title item values
this will get value from db, from this will get value from db, from i'm not sure how to
query row + next row query row + next row do this part????


for ( )
{
Item id
item title
iteam value????
}
for (int i=0; i<10; i++)
{

if (number[i] > max) {
max=number[i];
}
if (number[i] < min) {
min=number[i];
}

trient
Newbie Poster
13 posts since Apr 2008
Reputation Points: 10
Solved Threads: 0
 

Why not use order by clause in your query itself ?

$query = "select * from table order by colname [asc | desc ]";

[asc | desc ] is optional. You can sort the records in ascending order or descending order on one or multiple columns.
Or, you can also fetch the records from the table into an array and sort the array and get the max or min value from it.

nav33n
Purple hazed!
Moderator
4,465 posts since Nov 2007
Reputation Points: 524
Solved Threads: 356
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You