RSS Forums RSS

Sort Problem

Thread Solved
Reply
Posts: 192
Reputation: tanha is an unknown quantity at this point 
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Sort Problem

  #1  
May 17th, 2008
Hello everybody,
I am using WAMP:
1. PHP 5..
2. MySQL 5..
3. Apache 2..

the collation of my database and tables and fields are 'utf8_persian_ci', and also my query is in this format in PHP:
mysql_query("SET NAMES utf8");
mysql_query("SET CHARACTER SET utf8");
$query = mysql_query("SELECT * FROM tblName SORT BY fieldName COLLATE utf8_persian_ci");

this all utf8 is for my Arabic and persian words...

Problem:
I faced a problem on sorting english words, I dont know why the result on the browser is like the attachment
Attached Images
File Type: png sort.PNG (2.2 KB, 4 views)
AddThis Social Bookmark Button
Reply With Quote  
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: Sort Problem

  #2  
May 17th, 2008
just a guess check for extra spaces
Reply With Quote  
Posts: 192
Reputation: tanha is an unknown quantity at this point 
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Sort Problem

  #3  
May 17th, 2008
There is no more spaces...

just I dont know why doing like this
Reply With Quote  
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training
Posts: 192
Reputation: tanha is an unknown quantity at this point 
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Sort Problem

  #5  
May 17th, 2008
I dont have farsi sort problem, but see the attachment, the problem is that the english words are not sorted correctly ...

also I enter through the web, mysql command line, phpMyAdmin the following data:
Asad
asad
Asad
asad

and again by executing the following query I get the same dispaly:
SELECT * FROM tblName order by fieldName;

or

SELECT * FROM tblName order by fieldName COLLATE utf8_persian_ci;

The Result:
Asad
asad
Asad
asad
Last edited by tanha : May 17th, 2008 at 7:38 pm.
Reply With Quote  
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: Sort Problem

  #6  
May 17th, 2008
try

SELECT * FROM  table_name ORDER BY BINARY column_name ASC 
Reply With Quote  
Posts: 192
Reputation: tanha is an unknown quantity at this point 
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Sort Problem

  #7  
May 17th, 2008
Then if I try to use the binary, then it is ok, but you know that the binary sort according to ascii code of the character, then the following problem:
Asad
asad
Asad
asad
Bob
Tom
the output:

Asad
Asad
Bob
Tom
asad
asad

The sort must be like this:
Asad
Asad
asad
asad
Bob
Tom
Last edited by tanha : May 17th, 2008 at 8:06 pm.
Reply With Quote  
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: Sort Problem

  #8  
May 17th, 2008
SELECT * FROM table_name ORDER BY column_name, BINARY column_name ASC
Reply With Quote  
Posts: 192
Reputation: tanha is an unknown quantity at this point 
Solved Threads: 0
tanha tanha is offline Offline
Junior Poster

Re: Sort Problem

  #9  
May 17th, 2008
again it is the same result, nothing more... but I need the result as:
Asad
Asad
asad
asad
Bob
Tom
Reply With Quote  
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training

Re: Sort Problem

  #10  
May 17th, 2008
when i try it i get

ASAD
ASAD
ASAD
AsAD
Asad
Asad
asad
asad
BOB
Bob
bob
TOM
tom
tom
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the PHP Forum
Views: 987 | Replies: 10 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 3:04 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC