FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Wrong order





DanielXP
This is my code

Code:
$getitems = mysql_query("SELECT * FROM `creditstore` WHERE `cat` = 'cs' ORDER BY `price` ASC");
while($item = mysql_fetch_array($getitems))
{
    echo "<tr>
    <td style='border-top:1px solid #000000; border-right:1px solid #000000;'><div align='center'>
<input name='itemnu' type='radio' value='$item[id]'>
    </div></td>
    <td style='border-top:1px solid #000000; border-right:1px solid #000000;'>
$item[item]
    </td>
    <td style='border-top:1px solid #000000;'><div align='center'>
$item[price]
    </div></td>
  </tr>";
}


and this the price order it is coming out as

10
15
2
20
4
5
ncwdavid
DanielXP wrote:
This is my code

$getitems = mysql_query("SELECT * FROM `creditstore` WHERE `cat` = 'cs' ORDER BY `price` ASC");
while($item = mysql_fetch_array($getitems))
{
echo "<tr>
<td style='border-top:1px solid #000000; border-right:1px solid #000000;'><div align='center'>
<input name='itemnu' type='radio' value='$item[id]'>
</div></td>
<td style='border-top:1px solid #000000; border-right:1px solid #000000;'>
$item[item]
</td>
<td style='border-top:1px solid #000000;'><div align='center'>
$item[price]
</div></td>
</tr>";
}

and this the price order it is coming out as

10
15
2
20
4
5

So you want it to come out in the other order? just do ORDER BY price DESC
DanielXP
na i want it to come out as lowest to highest
Stubru Freak
You have probably used a character string data type for the price value. So it will be sorted as if it was text. You should use a numeric data type.
DanielXP
It is numbers

thats why the price shows in this

10
15
2
20
4
5
santium
Not the content. The table type. Change the price type to INT or something of the like. Any thing else will be sorted as text and ORDER BY will not work.
DanielXP
santium wrote:
Not the content. The table type. Change the price type to INT or something of the like. Any thing else will be sorted as text and ORDER BY will not work.


Thanks.
Related topics
Hows this for starters
Wrong number leads to drug arrest
Does anyone know the chronological order of the FF series?
Just-In-Time Debugger / Won't stop bugging me!
Do you know how to love?
Don't know what's wrong
Browser Compatibility issues
to play hard to get: is this ok?
Possibilitys implied in an object with mass traveling at c.
Space and planets
Crack the code! (Finished, but you can take a look)
Database not update. Where is my wrong code?
The time is wrong
Can't Delete files from my site
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.