hittesh_ahuja
11-20-2009, 09:43 AM
Hi guys,
i have a slight problem.
i am displaying data from a textbox and putting that variable in the database query the first time and the result is a radio group i get .
From there, i try to display another data whose variable is stored in a different db query but it doesnt take that variable.
if i replace the variable with a keyword ..it works..Please work.. i have highlighted the variable.
[CODE]
#!C:/indigoampp/perl-5.10.0/bin/perl.exe
use CGI;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use DBD::mysql;
print "Content-type: text/html\n\n";
print start_html();
print start_form( -name=>'search', -method=>'POST', -action=>'species_option.pl');
print p("Enter the first letter of the species");
print textfield(-type=>'text', -name=>'letter');
print submit();
print br();
print br();
my $driver='mysql';
my $database='hittesh';
my $letter=param('letter');
my $dsn="DBI:$driver:database=$database";
my $dbh = DBI->connect($dsn,"root" , );
$dbquery = qq(SELECT species_name FROM species_list where Alpha like '$letter') ;
$sth = $dbh->prepare($dbquery);
$sth->execute();
while (@row = $sth->fetchrow_array()) {
foreach $x (@row)
{
print radio_group(-name=>'species', -values=>$x);
print br();
}
}
$y=param('species');
print br();
print start_form(-name=>'list', -method=>'POST', -action=>'species_option.pl');
#print textfield(-type=>'text', -default=>$y);
print submit(-type=>'submit', -name=>'submit_data', -value=>'Get');
$dbq = qq(SELECT * FROM species_details where spec_name like '$y') ;
$sth1 = $dbh->prepare($dbq);
$sth1->execute();
#while (@row = $sth->fetchrow_array()) {
# foreach $ab (@row)
# {
print br();
print table({-border=>'2'});
print caption,b(('Displaying data for:',$y));
print hr();
print br();
print TR([th(['Observer Name','Date & Time','Latitude','Longitude','Species','Number Of Species'])]);
while (my $hashref= $sth1->fetchrow_hashref()) {
print br();
print TR();
print td( " $hashref->{'obs_name'}\n");
print td( " $hashref->{'datetime'}\n");
print td( " $hashref->{'latitude'}\n");
print td( " $hashref->{'longitude'}\n");
print td( " $hashref->{'spec_name'}\n");
print td( " $hashref->{'no_of_spec'}\n");
}
print br();
i have a slight problem.
i am displaying data from a textbox and putting that variable in the database query the first time and the result is a radio group i get .
From there, i try to display another data whose variable is stored in a different db query but it doesnt take that variable.
if i replace the variable with a keyword ..it works..Please work.. i have highlighted the variable.
[CODE]
#!C:/indigoampp/perl-5.10.0/bin/perl.exe
use CGI;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use DBD::mysql;
print "Content-type: text/html\n\n";
print start_html();
print start_form( -name=>'search', -method=>'POST', -action=>'species_option.pl');
print p("Enter the first letter of the species");
print textfield(-type=>'text', -name=>'letter');
print submit();
print br();
print br();
my $driver='mysql';
my $database='hittesh';
my $letter=param('letter');
my $dsn="DBI:$driver:database=$database";
my $dbh = DBI->connect($dsn,"root" , );
$dbquery = qq(SELECT species_name FROM species_list where Alpha like '$letter') ;
$sth = $dbh->prepare($dbquery);
$sth->execute();
while (@row = $sth->fetchrow_array()) {
foreach $x (@row)
{
print radio_group(-name=>'species', -values=>$x);
print br();
}
}
$y=param('species');
print br();
print start_form(-name=>'list', -method=>'POST', -action=>'species_option.pl');
#print textfield(-type=>'text', -default=>$y);
print submit(-type=>'submit', -name=>'submit_data', -value=>'Get');
$dbq = qq(SELECT * FROM species_details where spec_name like '$y') ;
$sth1 = $dbh->prepare($dbq);
$sth1->execute();
#while (@row = $sth->fetchrow_array()) {
# foreach $ab (@row)
# {
print br();
print table({-border=>'2'});
print caption,b(('Displaying data for:',$y));
print hr();
print br();
print TR([th(['Observer Name','Date & Time','Latitude','Longitude','Species','Number Of Species'])]);
while (my $hashref= $sth1->fetchrow_hashref()) {
print br();
print TR();
print td( " $hashref->{'obs_name'}\n");
print td( " $hashref->{'datetime'}\n");
print td( " $hashref->{'latitude'}\n");
print td( " $hashref->{'longitude'}\n");
print td( " $hashref->{'spec_name'}\n");
print td( " $hashref->{'no_of_spec'}\n");
}
print br();