#!/usr/bin/perl -w use strict; use CGI; use DBI; use CGI::Carp qw(fatalsToBrowser); #Create new CGI object my $cgi = new CGI; #Connect to DB my $dbh = DBI->connect("DBI:mysql:XXXXX:XXXXX","XXXXX","XXXXX") or die $DBI::errstr; #Print html header print $cgi->header("text/html"); #pull in keyword from form my $keyword = $cgi->param("keyword"); #prepare statement my $sth = $dbh->prepare("SELECT * FROM `productTable` WHERE `mfg` like '%$keyword%' OR `productID` like '%$keyword%' OR `desc` like '%$keyword%'") or die; #execute statement $sth->execute() or die; #print results while (my $rec = $sth->fetchrow_hashref) { print qq(
| $rec->{mfg} | $rec->{productID} | $rec->{desc} |