•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,468 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,024 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 339 | Replies: 1
![]() |
•
•
Join Date: Apr 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
arrange values from row of database in php from max to min, from min to max and value
#1
May 14th, 2008
Hi,
I've these values:
a) < 100 000 = 5 points
b) 100 000 - 250 000 = 4 points
c) > 250 000 = 3 points
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????
<table>
<tr>
for ( )
{
<td>Item id</td>
<td>item title</td>
<td>iteam value????</td>
}
</tr>
<table>
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????
<table>
<tr>
for ( )
{
<td>Item id</td>
<td>item title</td>
<td>iteam value????</td>
}
</tr>
<table>
for (int i=0; i<10; i++)
{
if (number[i] > max) {
max=number[i];
}
if (number[i] < min) {
min=number[i];
}•
•
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation:
Rep Power: 8
Solved Threads: 239
Re: arrange values from row of database in php from max to min, from min to max and value
#2
May 14th, 2008
Why not use order by clause in your query itself ?
[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.
php Syntax (Toggle Plain Text)
$query = "select * from table order by colname [asc | desc ]";
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.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
*PM asking for help will be ignored*
*PM asking for help will be ignored*
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
amd avatar backup blue gene breach business chips daniweb data data protection database development dos energy enterprise europe gentoo government hardware hp ibm ibm. news it linux medicine memory microsoft news open source openoffice pc php ps3 red hat rss russia searchmonkey security server sun supercomputer supercomputing trends ubuntu web working x86 xslt y!os ydn
- Previous Thread: Profile Help needed
- Next Thread: Page Navigation



Linear Mode