this returns 1 row
this returns {"items":"title","Jo0993"}
this is the format i want
({
"items": [
{
"title": "Valls"
},
{
"title": "AUT15605"
},
{
"title": "10UT15605"
}
]
})
My Try on ur suggestion
my $dbh = DBI->connect("DBI:mysql:$dbname:$host", $usr, $pwd, {
RaiseError => 1,
}) or die $DBI::errstr;
my $sth = $dbh->prepare("SELECT titles FROM tbl_1");
$sth->execute();
my $Data = $sth->fetchall_arrayref();
my %output;
foreach my $Data (@$Data) {
my ($title) = @$Data;
%output = (
'items' => [("title" => "$title")]
);
}
my $encoded = encode_json \%output;
print $Cgi->header( -type => 'application/json' ),$encoded;
|