943,648 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1354
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
May 17th, 2008
0

Sort Problem

Expand Post »
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:
PHP Syntax (Toggle Plain Text)
  1. mysql_query("SET NAMES utf8");
  2. mysql_query("SET CHARACTER SET utf8");
  3. $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 Thumbnails
Click image for larger version

Name:	sort.PNG
Views:	35
Size:	2.2 KB
ID:	6096  
Similar Threads
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 17th, 2008
0

Re: Sort Problem

just a guess check for extra spaces
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: Sort Problem

There is no more spaces...

just I dont know why doing like this
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: Sort Problem

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 8:38 pm.
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 17th, 2008
0

Re: Sort Problem

try

PHP Syntax (Toggle Plain Text)
  1. SELECT * FROM table_name ORDER BY BINARY column_name ASC
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: Sort Problem

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 9:06 pm.
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 17th, 2008
0

Re: Sort Problem

SELECT * FROM table_name ORDER BY column_name, BINARY column_name ASC
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008
May 17th, 2008
0

Re: Sort Problem

again it is the same result, nothing more... but I need the result as:
Asad
Asad
asad
asad
Bob
Tom
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
May 17th, 2008
0

Re: Sort Problem

when i try it i get

ASAD
ASAD
ASAD
AsAD
Asad
Asad
asad
asad
BOB
Bob
bob
TOM
tom
tom
Reputation Points: 11
Solved Threads: 7
Junior Poster in Training
amigura is offline Offline
71 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Can i load my page before displaying it ??
Next Thread in PHP Forum Timeline: php form submitting empty variables





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC