This is for my ZipCodeSearch Plugin.
I want to sort the results ASC by distance, but 'distance' is not column in my table.
How can I do the sort?
$link_db->select_options ('ORDER BY Add_Date ASC') || return $GT::SQL::error;
my $sth = $link_db->select( GT::SQL::Condition->new(
isValidated => '=' => 'Yes',
ExpiryDate => '>=' => time
) );
my $temp_distance;
while (my $link = $sth->fetchrow_hashref)
{
while (my $link = $sth->fetchrow_hashref)
{
$temp_distance = distance($olat, $olon, $link->{Latitude}, $link->{Longitude}, $unitcode);
if($temp_distance <= $dist)
{
$link_count++;
$link->{distance} = $temp_distance;
$link = Links::SiteHTML::tags('link', $link);
push (@link_results_loop, $link);
}
}
}
Thanks
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
I want to sort the results ASC by distance, but 'distance' is not column in my table.
How can I do the sort?
Code:
my $link_db = $DB->table('Links') || return $GT::SQL::error; $link_db->select_options ('ORDER BY Add_Date ASC') || return $GT::SQL::error;
my $sth = $link_db->select( GT::SQL::Condition->new(
isValidated => '=' => 'Yes',
ExpiryDate => '>=' => time
) );
my $temp_distance;
while (my $link = $sth->fetchrow_hashref)
{
while (my $link = $sth->fetchrow_hashref)
{
$temp_distance = distance($olat, $olon, $link->{Latitude}, $link->{Longitude}, $unitcode);
if($temp_distance <= $dist)
{
$link_count++;
$link->{distance} = $temp_distance;
$link = Links::SiteHTML::tags('link', $link);
push (@link_results_loop, $link);
}
}
}
Thanks
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com