# create statement handle my $sth = $dbh->prepare(" SELECT ArchiveID,ArchiveName AS Name, ArchiveBrowseLocation AS Location FROM tblArchive WHERE ArchiveCategory LIKE '%$searchterm%' ORDER BY '$searchorder'"); #execute SQL search $sth->execute(); #create a reference to the search results $array_ref = $sth->fetchall_arrayref(); #Dereference the data structure returned by the #preceding line. #For each row in the returned array reference foreach my $row(@$array_ref) { my ( $ArchiveID, $Name, $Location ) = @$row; } #Sort statement in here. Something like the following? #@$row = sort { $name1 cmp $name2 } @$row; #output to another script to layout the HTML to follow