I would handle this in a slightly different manner. I don't use bind_columns() only because that's not the way I was taught. Therefore, this method works for me when I am trying to figure out what data is where and how its being fetch'd.
my $data = qq(SELECT search, engine, time FROM searches WHERE DATE_SUB
++(CURDATE(),INTERVAL 7 DAY) <= time);
my $ref = $dbh->selectall_arrayref($data);
# For fun you can even check the number of rows returned
print "Total Searches: ". ($#{$ref} + 1) ."<br>\n";
for my $row (0 .. $#{$ref}) {
print "$ref->[$row][0] $ref->[$row][1] on $ref->[$row][2]<br>\n";
}
This should print out all your data.
Update: I would also ensure that you are comparing like data. Ie, I usually compare time in UNIX_TIMESTAMP() format. Therefore I would change your query to be something like this:
my $data = qq(SELECT search, engine, time FROM searches WHERE UNIX_TIMESTAMP(DATE_SUB(CURDATE(),INTERVAL 7 DAY)) <= UNIX_TIMESTAMP(time));
Eric
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.