RE: [PHP] still problem with getting HIGHest and LOWest VALUES
| From: | Don Read | Date: | Sun, 30 Sep 2001 17:35:26 +0000 |
| Subject: | RE: [PHP] still problem with getting HIGHest and LOWest VALUES | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-69375@lists.php.net to get a copy of this message | ||
On 30-Sep-2001 Teqila MAN wrote:
> The table has values :
>
> id - price
> 1 - 150000
> 2 - 24000
> 3 - 65000
> 4 - 200000
>
>
> When i want to sort it
>
> $x = mysql_query("SELECT * FROM $dealer_tabela ORDER BY cena");
> while ($row = mysql_fetch_array($x))
> {
> $id=$row["id"];
> $price=$row["price"];
> print("$price<br>\n");
> }
>
> It returns me values :
> 150000
> 200000
> 24000
> 65000
>
> What is false! It sorts this by getting first values ? How to fix it ?
You defined cena as a VARCHAR ?, it will sort as a string. Define it as INT (or
FLOAT).
If you can't change it use:
SELECT id, cena + 0 as price FROM $dealer_tabela ORDER BY price
Regards,
--
Don Read dread@texas.net
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.