Sorry it took so long to get around to this, had a very insane past few days. The way this works is we're going to create a second table that is the following:
Code:
CREATE TABLE images(image int(11) primary key auto_increment, name varchar(40) unique, link text);
This will make a new table that has three columns in it, the first column is named image and is the number of the image as used in the PHP code I gave you the first time around. The second column is the name of the image, blah.gif or null.jpg, the image names all must be unique. The third column is the link for the image.
Instead of the PHP used above we will be using a new script:
PHP Code:
<?php $link = mysql_connect('localhost', 'mysql_user', 'mysql_password') or die("Could not connect: ".mysql_error());
$db_select = mysql_select_db('db_name',$link) or die("Could not select: ".mysql_error());
$max =10;//Set this to how many images you have.
$d=date("z");
$query = "SELECT * FROM `updated`";
$result = mysql_query($query);
$l = mysql_fetch_array($result);
if($d > $l[0] || ($d == 0 && $l[0] == 365)){
$img = rand(1,$max);
$query = "UPDATE TABLE `updated` SET updated = $d && image = $img where updated= $l[0]";
$result = mysql_query($query);
$query = "SELECT * FROM `images` where image=$img";
$result = mysql_query($query);
$array = mysql_fetch_array($result);
echo '<a href="'.$array[2].'"><img src="images/'.$array[1].'" alt="Daily Image"></a>';
}
else{$query = "SELECT * FROM updated, images WHERE updated.image = images.image";
$result = mysql_query($query);
$array = mysql_fetch_array($result);
echo '<a href="'.$array[4].'"><img src="images/'.$array[3].'" alt="Daily Image"></a>';}
mysql_close($link);?>
Make sure to run this SQL command too if you haven't already:
Code:
CREATE TABLE updated(updated int(11),image int(11));
INSERT INTO `updated` values(0,1);
All you have to do to insert a new picture is run this SQL changing IMAGE_NAME for the image's name and LINK_LOCATION to the link (including
http://) DO NOT REMOVE THE QUOTES!!:
Code:
INSERT INTO `images` VALUES(NULL,'IMAGE_NAME','LINK_LOCATION');
An example of this would be:
Code:
INSERT INTO `images` VALUES(NULL,'blah.png','http://example.com');