Webmaster Forum

Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2009, 10:08 PM
v7n Mentor
Latest Blog:
None

 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 665
iTrader: 0 / 0%
Leon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of light
[MySQL] Order By Issue

Sup Folks.

I have a problem with ORDER BY and numbers + characters. I have strings in my database that look like this: "$75.00 or XYZ for $300.00" and most of the strings look more like "$125", "$235" etc. well when you order by the field by say DESC it does this:

"$75.00 or XYZ for $300.00"
"$235"
"$125"

When what I really want is:

"$235"
"$125"
"$75.0 or XYZ for $300.00"

Someone suggested that I do "ORDER BY string+0" and that gives a great result if you just want "ASC" but I want to have the ability to do both ASC and DESC. I can't make the type a INT either because they want to be able to put normal characters in the string.
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #2 (permalink)  
Old 07-05-2009, 03:12 PM
Izzmo's Avatar
v7n Mentor
Latest Blog:
Starting p90x today

 
Join Date: 11-01-03
Location: Kansas City
Posts: 1,346
iTrader: 1 / 100%
Izzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web proIzzmo is a highly respected web pro
Send a message via ICQ to Izzmo Send a message via AIM to Izzmo Send a message via MSN to Izzmo Send a message via Yahoo to Izzmo
This is because the column is a String, not a double.

You need to set the column as a DOUBLE and get the double type from the database, then stick a '$' (dollar sign) in front of it when you output it to the user.
__________________
Izzmo
Coding Guru Extraordinaire
ZeroWeb Hosting & Design - Customizable hosting for every type of user!
Digg this Post!Add Post to del.icio.us
Reply With Quote
  #3 (permalink)  
Old 07-13-2009, 03:35 PM
v7n Mentor
Latest Blog:
None

 
Join Date: 10-13-03
Location: Atlanta, GA
Posts: 665
iTrader: 0 / 0%
Leon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of lightLeon is a glorious beacon of light
I ended up restructuring the DB to do it correctly.
Digg this Post!Add Post to del.icio.us
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
WOMD - Issue or Non-issue John Scott Controversial Social Issues 1 08-02-2007 09:30 AM
mySQL Issue Sketch Coding Forum 8 01-17-2007 12:09 AM


Sponsor Links
Get exposure! Contextual Links V7N SEO Blog V7N Directory


Site Navigation: v7n Home .::. Graphics .::. Scripts .::. V7N Web Directory .::. V7N Technology Blog .::. V7N Affiliate Program .::. Advertise

Partners: Search Engine Optimisation .::. Dedicated Server Hosting .::. Webmaster Talk .::. CPA Affiliates .::. Dedicated Server Hosting

Site Sponsored by a Hivelocity Dedicated Server.
SEO Consult, International SEO Experts
Dedicated Server Hosting
All times are GMT -7. The time now is 02:03 PM.
© Copyright 2008 V7 Inc
Powered by vBulletin
Copyright © 2000-2009 Jelsoft Enterprises Limited.


Search Engine Optimization by vBSEO 3.3.0 ©2009, Crawlability, Inc.