Order by price, PHP MYSQL output issues

93jordanaj
93jordanaj used Ask the Experts™
on
I am trying to output from a MYSQL database using PHP ordered by price. Everything works, however the results are ordered by the first digit:

£10.00
£25.00
£3.00
£45.00
£5.00
£55.00
etc.

The code I used is pretty straight forward and shown below, but how do I make it actually order by price and not the first digit?
$printing = mysql_query("SELECT * FROM products WHERE listed='1' ORDER BY price") or die(mysql_error());

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
what is the data type of the field "price"?

Author

Commented:
'Varchar', should I change it to 'int'?

Author

Commented:
I just changed it - problem solved. Thanks for making me double check.

Author

Commented:
Thanks for making me double-check. Solved it by myself, but probably wouldn't have looked there without you.
Is the pound (£) sign saved in the db as well? If it is you could try

$printing = mysql_query("SELECT * FROM products WHERE listed='1' ORDER BY price + 0") or die(mysql_error());

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial