note 79070 deleted from function.sort by betz
| From: | betz@php.net | Date: | Fri, 09 Nov 2007 08:43:01 +0000 |
| Subject: | note 79070 deleted from function.sort by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-132142@lists.php.net to get a copy of this message | ||
Note Submitter: atiqw at yahoo dot com
----
I am having problem with sorting an array.
Here's my code and the output, help please. I tried sorting after saving into mysql, even mysql
didn't sort that array data properly, what's wrong? please help ...
-----
code
-----
<?php
$host="localhost";
$userName="root";
$pass="";
$list = array();
$j = 0;
$cn = mysql_connect($host, $userName, $pass);
mysql_select_db('test', $cn);
$sql = "select * from emp order by fname";
//pass to record set
$rs = mysql_query($sql, $cn);
while($row = mysql_fetch_array($rs))
{
print $row["keywords"]."<BR>\n";
$values = explode(",", $row["keywords"]);
for($i=0; $i<sizeof($values); $i++)
{
$list[$j++] = $values[$i];
}
}
print "<br><br>\n";
sort($list);
for($i=0; $i<sizeof($list); $i++){
echo $list[$i]."<br />\n";
$sql = "insert into keywords(keywords, display) values
('$list[$i]', '')";
//pass to record set
$rs = mysql_query($sql, $cn);
}
?>
-------
output
-------
AJax
c++
Cobol
development
jeaps
joseph
josh
kevin
orange
philip
programming
rob
shirt
suv
warraich
web
apple
atiq
Cars
computer
java
Pant
-----------------
Thanks in advance
Regards:
Atiq warraich
atiqw@yahoo.com
-----------------