Uhhh, isn't that what you want it to do? / Told us you wanted it to do?outdoorxtreme1 wrote: then I get an echo but the pictures appear randomly each time the page is refreshed.
Your posts title its "Need help with random image code"
So yea...
Moderator: General Moderators
What??? Then why on earth have you been using ORDER BY RAND()?outdoorxtreme1 wrote:In my very first post I asked if someone please tell me what I need to change or add to allow this script to display a new image weekly instead of every time the page is refreshed.
Code: Select all
if(date('N') == 7) // If today is sunday
{
mysql_query("INSERT INTO `imageTable` SET `weekOf` = '" . date('Y-m-d') . "', `image` = (SELECT `image` FROM `links` ORDER BY RAND() LIMIT 1);");
}
// Display
$result = mysql_query("SELECT `image` FROM `imageTable` ORDER BY `weekOf` DESC LIMIT 1;");
$result = mysql_fetch_object($result);
echo '<img src="' . $result->image . '" />';