[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: Sorting output to be returned to a HTML page using PHP



On 22 May, Antonin Novak wrote:
>                        	function EntryCompare($a,$b) 
>                        		{ 
>                        			$sortfield = "sn"; 
>                        			if($a[$sortfield]==$b[$sortfield]) 
>                       					 { 
>                        					return 0; 
>                        				} 
> 
>                        			if($a[$sortfield]>$b[$sortfield]) 
>                        				{ 
>                        					return 1; 
>                        				} 
>                        			else 
>                       					 { 
>                        					return -1; 
>                        				} 
>                       			 } 
> 
> I have tried  the sort statement within the "for" 	statement, 
> efining $a=array($info) and numerous combinations of array " ( and
> info. 

Results are multi-valued. Try using

if ($a[$sortfield][0]==$b[$sortfield][0])
if ($a[$sortfield][0]>$b[$sortfield][0])

This probably belongs on a php mailing list. 

-- 
Doug Nazar
Dragon Computer Consultants Inc.
Tel: (416) 708-1578     Fax: (416) 708-8081