User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,708 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,407 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 437 | Replies: 10 | Solved
Reply
Join Date: Aug 2007
Posts: 147
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
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  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
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  
Join Date: Aug 2007
Posts: 147
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
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  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 7
amigura's Avatar
amigura amigura is offline Offline
Junior Poster in Training
Join Date: Aug 2007
Posts: 147
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
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  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
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  
Join Date: Aug 2007
Posts: 147
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
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  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
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  
Join Date: Aug 2007
Posts: 147
Reputation: tanha is an unknown quantity at this point 
Rep Power: 0
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  
Join Date: Jan 2008
Posts: 71
Reputation: amigura is an unknown quantity at this point 
Rep Power: 1
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.

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

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC