in reply to Re^4: Search 2 columns
in thread Search 2 columns
By the way, when I do something like this with a MySQL database of my own, I get the sort of results that I think you want:
It also works as expected if the second "like ?" applies to the same column as the first one.my @search = qw/%this% %that%/; my $sql = "select something from table where column1 like ? or colu +mn2 like ?"; my $sth = $dbh->prepare( $sql ); $sth->execute( @search );
As for the table layout, you might try something like this:
(expression).my $left_col = ''; for my $table_row ( @$table_ref ) { my @table_cols = map { (defined($_) && /\S/) ? $_ : ' '} @$ta +ble_row; my $cell_str = join( '<br>', "<b>$table_cols[0]</b>", @table_cols[1..$#table_cols] ); if ( $left_col eq '' ) { $left_col = $cell_str; } else { push @rows, Tr([ $left_col, $cell_str ]); $left_col = ''; } } $page .= table( {-border => 0, width=> 550}, \@rows);
(Again, that's not tested, but it should be close to what you want. Updated to fix the sigils on table_cols in the "join()" expression.)
|
|---|