FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a 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


Last edited by DanielXP on Wed Dec 20, 2006 10:36 pm; edited 1 time in total
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.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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