note 50766 deleted from function.list by aidan

From: Date: Tue, 26 Apr 2005 09:11:38 +0000
Subject: note 50766 deleted from function.list by aidan
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88550@lists.php.net to get a copy of this message
Note Submitter: venkatesh at lammersmedical dot com ---- //////////////////////////////////////////////////////// // pp_CreateSortedList($database,$colname) // // Synopsis: // // L:69 Row length=((total number of elements in the databse-column count)/coulmn count) // L:73 Getting nameline from the database // L:77 Builds a list table ($NameLine) from a database table // and finds the key of corresponding column name for // sorting the given $database by it's coulmn name // (call by reference) // L:94 Property line invocation // L:98 Reverse sorting // Inputs: // $database : List table of data // $colname : column name of the $database // $sort_typ : It referece the the type of sorting accarding to the requirement // // Returns: // Sorted database table by it's coulmn name // // Error handling: // -none (not yet)- //////////////////////////////////////////////////////// //calculation of the length of the row in the database function pp_CreateSortedList(&$database,$colname=null,$sort_typ=null){ $NameLine=array(); $Total=count($database,COUNT_RECURSIVE); $column_count; $column_count=count($database); if($column_count<=1){ $row_Length=1; } else{ $row_Length=(($Total-$column_count)/$column_count); } for($i=0;$i<$row_Length;$i++) { $j=0; array_push($NameLine,$database[$j][$i]); } $find_key=0; while ($column_name = current($NameLine)){ if ($column_name == $colname){ $find_key = key($NameLine); } next($NameLine); } // echo "\r"; $tmplist = array(); $refer=array(); $idx = 0; foreach($database as $cl){ if ($idx == 0){ $NameLine = $cl; } else{ $tmplist[$idx-1] = pp_CreatePropLine($NameLine, $cl); } $idx++; } if($colname!=null){ if($sort_typ=='REV'){ rsort($tmplist,$find_key); } foreach ($tmplist as $key => $row) { $ReferenceCol[$key] = $row[$colname]; } array_multisort($ReferenceCol,SORT_DESC,$tmplist); } return($tmplist); }

« previous php.notes (#88550) next »