Greenguy's Board


Go Back   Greenguy's Board > Programming & Scripting
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2006-02-20, 12:53 PM   #1
juggernaut
Registered User
 
juggernaut's Avatar
 
Join Date: Apr 2005
Location: Central Jersey! If I was rich and powerful I would dress as my avatar does.
Posts: 1,448
Send a message via Yahoo to juggernaut
weekly image rotation?

I found this script

<script type="text/javascript" language="JavaScript">
var now = new Date ();
var day = now.getDay();
//REMEMBER- the week begins on SUNDAY
if(day == 0) document.write("<a href='YOUR-LINK-HERE'><img src='/images/sundayimage.gif' alt='sunday' width='125' height='80' border='0'></a>");
if(day == 1) document.write("<a href='YOUR-LINK-HERE'><img src='/images/mondayimage.gif' alt='sunday' width='125' height='80' border='0'></a>");
if(day == 2) document.write("<a href='YOUR-LINK-HERE'><img src='/images/tuesdayimage.gif' alt='sunday' width='125' height='80' border='0'></a>");


And its pretty close to what I need. I need a script that will rotate out my "host of the week" image on my site. This script does it everyday and then will revert back to the sunday image after the week has ended.
Right now its getting to be a pain in the ass to manage the changes. I would perfer to put up a directory with 52 images in it and rotate threw them every sunday. Each new image would have the hosts name as the alt text and the link would take you to there bio, etc. I would perfer something simple like javascript but everyplace I look all the codes are for daily or monthly rotation. I have phpadsnew but to be honest its just a pain in the ass to get it to work with something simple like this. Maybe I should not say simple being i cant do it, but I know this is not super coding. Anyhelp would be great. Jugg....
juggernaut is offline   Reply With Quote
Old 2006-02-21, 03:41 PM   #2
Beaver Bob
Porn Blog Addict
 
Beaver Bob's Avatar
 
Join Date: Oct 2005
Location: Las Vegas, Nevada
Posts: 715
Send a message via ICQ to Beaver Bob
Here is a javascript function that will let you get the number of the week the first week is week 1 and the last week being 52. Its not perfect but it does work.

remember in javascript January = 0 and December = 11
PHP Code:
function getWeek(year,month,day){
    
//lets calc weeknumber the cruel and hard way :D
    //Find JulianDay 
    
month += 1//use 1-12
    
var Math.floor((14-(month))/12);
    var 
year+4800-a;
    var 
= (month)+(12*a)-3;
    var 
jd day Math.floor(((153*m)+2)/5) + 
                 (
365*y) + Math.floor(y/4) - Math.floor(y/100) + 
                 
Math.floor(y/400) - 32045;      // (gregorian calendar)
    //var jd = (day+1)+Math.Round(((153*m)+2)/5)+(365+y) + 
    //                 Math.round(y/4)-32083;    // (julian calendar)
    
    //now calc weeknumber according to JD
    
var d4 = (jd+31741-(jd%7))%146097%36524%1461;
    var 
Math.floor(d4/1460);
    var 
d1 = ((d4-L)%365)+L;
    
NumberOfWeek Math.floor(d1/7) + 1;
    return 
NumberOfWeek;        


I would just number my pictures 1.jpg thru 52.jpg and display them based on the week number. hope this helps.
Beaver Bob is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:59 PM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc