Posted by no on 11/10/06 17:03
On Fri, 10 Nov 2006 13:55:54 -0000, "password" <fatpipe@epiptaf.com>
wrote:
>hello, i am using an automatic image rotator (php) which rotates images on
>refresh or everytime a page is accessed and i was wondering if it is
>possible to make the image change on a daily basis instead. ive been hunting
>the net but dont seem to be able to find a script that would do this.
I did a similar thing recently with rotating headers. Instead of using
a date/day we just settled on using the session, so that the header
will remain stable for the life of the session - usually the time the
browser is open - but not change when moving between pages.
I just:
* did session_start() at the top of the pages
* set up MAXHEADERS as a define() constant for the maximum number of
headers
* uploaded 5 different files like header-?.jpg
* then called this function to return me the name of the current
header file:
function header_rotate() {
if (!isset($_SESSION['headername'])) {
$_SESSION['headername']='header-'.rand(1,MAXHEADERS).'.jpg';
}
return $_SESSION['headername'];
}
Chris R.
[Back to original message]
|