S
servicio.hispano
I'm new at this and can't get this to work. I have this form where I'm
trying to search by last name but the page where the results should be
come up blank. I know I must be missing something simple. I apologize
if this is the wrong place to post this. Here's my code:
sub name_search(){
print $q->header();
print $q->start_html();
# if($submit) {
my $dbh = DBI->connect("DBI:mysql
olicy",
"*******", "*******");
if($submit) {
my $sql = "SELECT polID, lname1, fname FROM
customers where lname1 = $lname1"; #trying to match the value in the
textfield
my $sth = $dbh->prepare($sql);
while(my($p, $l, $f) = $sth->fetchrow_array()){
print "<table>\n";
print
"<tr><td>$p</td><td>$l</td><td>$f</td></tr>\n";
print "</table>\n";
}
}else{
print $q->start_form();
print $q->hidden('op', 'name_search');
print $q->hidden('lname1', $lname1);
print "<table>";
print "<tr><td>Last Name</td><td>" .
$q->textfield('lname1', '$lname1', '', '') . $q->submit('submit',
'Search');
print "</td></tr>";
print "</table>";
print $q->end_form();
print $q->end_html();
#$sth->finish();
}
$dbh->disconnect();
}
The textbox and submit button shows up fine. I don't get any errors. I
just don't get anything in the results. It just goes to a blank page. I
know I've gotten this to work before but because of my job I haven't
had the chance to practice. What I learned I have forgotten.
Thanks for any help.
trying to search by last name but the page where the results should be
come up blank. I know I must be missing something simple. I apologize
if this is the wrong place to post this. Here's my code:
sub name_search(){
print $q->header();
print $q->start_html();
# if($submit) {
my $dbh = DBI->connect("DBI:mysql
"*******", "*******");
if($submit) {
my $sql = "SELECT polID, lname1, fname FROM
customers where lname1 = $lname1"; #trying to match the value in the
textfield
my $sth = $dbh->prepare($sql);
while(my($p, $l, $f) = $sth->fetchrow_array()){
print "<table>\n";
"<tr><td>$p</td><td>$l</td><td>$f</td></tr>\n";
print "</table>\n";
}
}else{
print $q->start_form();
print $q->hidden('op', 'name_search');
print $q->hidden('lname1', $lname1);
print "<table>";
print "<tr><td>Last Name</td><td>" .
$q->textfield('lname1', '$lname1', '', '') . $q->submit('submit',
'Search');
print "</td></tr>";
print "</table>";
print $q->end_form();
print $q->end_html();
#$sth->finish();
}
$dbh->disconnect();
}
The textbox and submit button shows up fine. I don't get any errors. I
just don't get anything in the results. It just goes to a blank page. I
know I've gotten this to work before but because of my job I haven't
had the chance to practice. What I learned I have forgotten.
Thanks for any help.