note 79069 rejected from function.sort by betz

From: Date: Fri, 09 Nov 2007 08:42:39 +0000
Subject: note 79069 rejected from function.sort by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-132141@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 -----------------

« previous php.notes (#132141) next »