Hello, I have a table that stores image information in it, such as width, height, link, alt(message), and stuff like that.
I added this subroutine that returns the standard format of html to print that "image". here is what I did:
sub Get_Banner_Rotator {
my ($row, $dbh, $sth, $html_content);
$sth = $dbh->prepare (qq{ SELECT * FROM Banner_Rotator ORDER BY RA
+ND() LIMIT 1 });
$sth->execute();
$row = $sth->fetchrow_hashref();
if (defined($row) && $row ne "") {
$html_content = qq~Print the link and image~;
}
$html_content =~ s/{{imageurl}}/$imageurl/g;
return($html_content);
}
My problem, is that it keeps grabbing the VERY SAME record. Number 1.
Am I missing something here? I do something similar on another one of my websites, and it works, however it is doing the MySQL clause like this:
"SELECT id FROM table
WHERE u = '1'
ORDER BY RAND() LIMIT 1"
That one works.
of course it is ONLY getting the id from it, but shouldn't mine also grab a random record?
I've only added 3, at this point, but it shows that one only, every single time I refresh the page.
Do you see something wrong there?
thx,
Richard
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.