Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

im trying to sort names from sql

while($ddfg = mysql_fetch_array($result_skey002))
{
    $total = $ddfg['name2'];
}
sort($total);
echo $total;

Somthing like that ..,
Im work with name in hebrew so this its doesnt working:

$query_skey002 = "SELECT * FROM s_keywords ORDER BY `name2` ASC";

I have no idea how to work with php sort function.
Thanks for the helpers

share|improve this question
    
Apart from the fact that you should do that in the database, you are overwriting your variable (a string) in the loop and feeding a string to an array function. – jeroen Jul 17 '13 at 20:44
    
$total = $ddfg['name2']; should be $total[] = $ddfg['name2']; and echo $total should be something else – Orangepill Jul 17 '13 at 20:52

Don't sort in PHP. Your database query is doing that. No need to sort twice. MySQL can sort hebrew text if you use the correct charset/collation.

http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html

Update:

Here is a working example of inserting hebrew into a mysql table. I tested it and it definitely works:

mysql> create table hebrew_table (my_column varchar(128)) charset=hebrew;
Query OK, 0 rows affected (0.03 sec)

mysql> insert into hebrew_table (my_column) values ('אחד');
Query OK, 1 row affected (0.00 sec)

mysql> select * from hebrew_table;
+-----------+
| my_column |
+-----------+
| אחד       |
+-----------+
1 row in set (0.01 sec)
share|improve this answer
    
Mysql query dont know to do that with hebrew. – Niv_H Jul 17 '13 at 20:45
    
Look to see if mysql supports a charset/collation that can sort hebrew. – Asaph Jul 17 '13 at 20:47
    
@Niv_H - it should work in MySQL. Is the table using the utf8 character set and collation for that column and is your database connection using UTF8 as well for the client connection character set? – Eric Petroelje Jul 17 '13 at 20:50
    
you might be able to cast as hebrew_general_ci – Samuel Cook Jul 17 '13 at 20:50
    
I tried.. sql not suppurt hebrew, when i insert string in hebrew its showing in gibberish – Niv_H Jul 17 '13 at 20:51

Your database query is proper. It will sort result when your SQL query get executed.

You may improve your select SQL query using below one..

$query_skey002 = "SELECT * FROM `s_keywords` ORDER BY `name2` ASC";
share|improve this answer
    
Sorry but dont work.. – Niv_H Jul 17 '13 at 20:59
    
MySQL has very less support for other languages as well as php5.5 deprecated MYSQL. Try for MySQLi.. – Pank Jul 17 '13 at 21:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.