Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: Searching a text file

by tachyon (Chancellor)
on Nov 14, 2004 at 09:18 UTC ( #407669=note: print w/replies, xml ) Need Help??

in reply to Re^2: Searching a text file
in thread Searching a text file

Why would you *want* to search for a string in any field? You last field looks like a boolean (on off) your 4th field looks boolean too (male female). If you are searching for emails you would not really want to look there....

Presumably you have a data entry form. This can also be a search form, just add a button that says search. When a user enters data in one or more fields and clicks search all you do is make a query like:

$sth = $dbh->prepare('SELECT foo,bar,baz FROM widget WHERE foo=? AND b +ar=? AND baz=?'); $sth->execute($foo,$bar,$baz);

where you dynamically construct the WHERE clause depending on how many fields the user enters data into. To search *all* the fields for the one string the syntax would simply be OR, not AND and include all the fields you want to search.....

$sth = $dbh->prepare('SELECT foo,bar,baz FROM widget WHERE foo=? OR ba +r=? OR baz=?'); $sth->execute($str,$str,$str);

DBD::SQLite might suit you better.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://407669]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2018-07-22 13:04 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (454 votes). Check out past polls.