I'm the same guy who posted about timestamps in mysql yesterday and now I've run into a problem with my SELECT only bringing back one result (when there are 6).
my $data = qq(SELECT search, engine, time FROM searches WHERE DATE_SUB
+(CURDATE(),INTERVAL 7 DAY) <= time);
my $sth = $dbh->prepare($data);
$sth->execute() or die $dbh->errstr;
my ($search, $engine, $date);
$sth->bind_columns(\$search, \$engine, \$date);
while($sth->fetch)
{
print "$search $engine on $date<br>";
}
This is the data found in my database as told by PHPMyAdmin
Edit Delete 1 this is fun Google 2006-08-
+10 10:48:21
Edit Delete 2 oh yeah About 2006-08-10
+ 11:15:18
Edit Delete 3 yet another About 2006-08-10
+11:15:26
Edit Delete 4 this is fun Excite 2006-08-1
+0 11:15:35
Edit Delete 5 another on this Excite 2006-0
+8-10 11:15:44
Edit Delete 6 testing Dogpile 2006-08-10 11:15
+:592006-08-10 11:15:59
It prints
this is fun Google on 006-08-10 10:48:21
But from the times, you can see each of these are within the last 7 days and I'm confused why it's not printing them, too.
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.