Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
my oops - here's the "search_item" code...
sub search_item($$$$) { #* # to search for a list of user IDs which match one criteria (ie: eye +_clr=1) # searches can only happen with the logged in user # we must not include the logged in user in the search results! # nor should we include those that are banned or security level 888 +or higher #* my ($db, $usersRef, $name, $value) = @_; # a DBH && a reference to a + list of users to search && the name of the item to search for && the + value the named item must be my @searched; # a list of UIDs which match the given name=value pair +s my $query = "select ID from users where $name='$value';"; my $resultsRef = sql_execute($db, $query); if ($resultsRef) { if (ref $resultsRef eq "ARRAY") { # we have multiple hits! my @array = @$resultsRef; foreach my $hit (@array) { # $hit is a hash reference. my %hash = %$hit; push @searched, $hash{ID}; } } else { # we only have one hit! my %hash = %$resultsRef; push @searched, $hash{ID}; } } # it is very possible to have an empty "searched" array. # this is totally ok. return @searched; # an array of uid's which matched the specified cr +iteria, minus the logged in user's uid #usage: my @results = search_item($db, \@uList, "eyes", "1"); }

In reply to Re^2: DB search results using DBI...execute by jamroll
in thread DB search results using DBI...execute by jamroll

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-19 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found