I am using fetchall_hashref to get data satisfying a condition from a mysql DB.The data retrieved will be stored in a hash and then be used futhur by a javascript function.
I want to retrieve all the rows of 3 columns and store it in a hash but not being able to do that.
The table structure..
the table data..
the code being used..
#!/usr/bin/perl -w
#print "Content-type: text/html\n\n";
use DBI;
use CGI;
use strict;
use warnings;
use diagnostics;
use Data::Dumper;
use CGI::Carp qw (fatalsToBrowser);
my $q = CGI->new;
print $q->header;
my $dsn = "DBI:mysql:Demo:localhost"; # Data source name
my $username = "mint"; # User name
my $password = "MINT123"; # Password
my $dbh;
my $sth;
my $b;
my $c;
# Database and statement handles
$dbh = DBI->connect($dsn, $username, $password);
my $hash = $dbh->selectall_hashref("SELECT `desc`,date1,riskval from FIR2 where date1 between date_sub(now(),INTERVAL 1 WEEK) and now() order by date1", 'riskval');
print Dumper($hash);
$b=join(",",$hash);
delete $_->{riskval} for values %$hash;
$dbh->disconnect();
The output i am getting in browser...
the output in putty..
As you can see I want to print the row where "riskval" is null,the value of "riskval" is 5 in 2 places but only 1 row is getting printed..
after i replaced selectall_hashref with selectall_arrayref i got the following error message in putty..
Please help..