[ { "info": "\t\t\t\t\t\t \n
John UK Male
\nKieth UK Male
" }, { "info": "\t\t\t\t\t\t \nJohn UK Male
\nKieth UK Male
" } ] ####
my $sth = $dbh->prepare("SELECT name country gender FROM tbl_U WHERE location = ?");
$sth->execute('UK');
my $result = $sth->fetchall_arrayref();
my $json_msg;
my %hash;
my @updated_data;
foreach my $result (@$result) {
my ($name, $country, $gender) = @$result;
$json_msg .= <$name $country $gender
HTML
;
%hash = ( "info" => $json_msg);
push( @updated_data, \%hash );
}
my $json = encode_json \@updated_data;
print $Cgi->header( -type => 'application/json' ),$json;
####
[
{
"info": "\t\t\t\t\t\t \nJohn UK Male
"
},
{
"info": "\t\t\t\t\t\t \nKieth UK Male
"
}
]