my @rows; my $z = @rows; # There is nothing in @rows yet, so $z is 0 if ($z = 0) { # but in any case, this will never return true! print "We are sorry, but your search did not return any results.

\n"; print "\n"; print "$tbl_ref\n"; } #### my $column = ( $type eq 'alpha' ) ? 'name' : "CONCAT_WS(' ',keywords,category)"; my $query = "SELECT name, address, city, phone FROM valley ". "WHERE $column LIKE ? ORDER BY name LIMIT ?,?"; my $sth = $dbh->prepare( $query ); $sth->execute( "%$search%", $start-1, $per_page+1 ); my $table_ref = $sth->fetchall_arrayref; # here is where/how you check whether anything was returned: if ( ref( $table_ref ) ne 'ARRAY' or @$table_ref == 0 ) { ... } #### name1 name2 name3 name4 ... #### for my $table_row ( @$table_ref ) { my @table_cols = map { (defined($_) && /\S/) ? $_ : ' '} @$table_row; push @rows, Tr( \@table_cols ); } $page .= "" . table( {-border => 0, width=> 550}, \@rows) . "" . br(); #### $page .= '  ' x 35;