Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6179295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:38:01+00:00 2026-05-24T00:38:01+00:00

i know a little php. Can anyone tell me how to write a simple

  • 0

i know a little php. Can anyone tell me how to write a simple php script so that the image in the header changes every 5 seconds or so. I dont want to place any kind of links on that image just want to change the images . thank you :))

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T00:38:03+00:00Added an answer on May 24, 2026 at 12:38 am

    PHP can only provide the image, you need a little bit of JavaScript to trigger events fetching the new images.

    Here’s a way to do it, adapted from http://javascript.internet.com/miscellaneous/random-image-rotator.html:

    <HTML>
    <HEAD>
    
    <!-- STEP ONE: The core of it: JavaScript... -->
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Original:  Robert Bui (astrogate@hotmail.com) -->
    <!-- Web Site:  http://astrogate.virtualave.net -->
    
    <!-- Begin
    var interval = 2.5; // delay between rotating images (in seconds)
    var random_display = 1; // 0 = no, 1 = yes
    interval *= 1000;
    
    var image_index = 0;
    image_list = new Array();
    image_list[image_index++] = new imageItem("http://www.something.com/image01.jpg");
    image_list[image_index++] = new imageItem("http://www.something.com/image02.jpg");
    image_list[image_index++] = new imageItem("http://www.something.com/image03.jpg");
    image_list[image_index++] = new imageItem("http://www.something.com/image04.jpg");
    var number_of_image = image_list.length;
    function imageItem(image_location) {
        this.image_item = new Image();
        this.image_item.src = image_location;
    }
    function get_ImageItemLocation(imageObj) {
        return(imageObj.image_item.src)
    }
    function generate(x, y) {
        var range = y - x + 1;
        return Math.floor(Math.random() * range) + x;
    }
    function getNextImage() {
        if (random_display) {
            image_index = generate(0, number_of_image-1);
        } else {
            image_index = (image_index+1) % number_of_image;
        }
        var new_image = get_ImageItemLocation(image_list[image_index]);
        return(new_image);
    }
    function rotateImage(place) {
        var new_image = getNextImage();
        document[place].src = new_image;
        var recur_call = "rotateImage('"+place+"')";
        setTimeout(recur_call, interval);
    }
    //  End -->
    </script>
    </HEAD>
    
    <!-- STEP TWO: Insert the onLoad event handler into your BODY tag  -->
    
    <BODY OnLoad="rotateImage('rImage')">
    
    <!-- STEP THREE: Copy this code into the BODY of your HTML document  -->
    
    <center>
    <img name="rImage" src="http://www.something.com/image01.jpg" width=120 height=90>
    </center>
    
    </BODY>
    </HTML>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this little script in PHP that send a simple request to
I know that this question have been asked several times. But I can't get
Does anyone know if there is a php library, or if there isnt, have
I've had quite a few problems and know that I can get some good
I'm writing a simple templating layer in PHP but I've got myself a little
can anyone give me a javascript that can do following. I have predefined price
I know a good amount of PHP, but know very little of Javascript. Basically,
I have a PHP script that runs as a background process. This script simply
I know a little about SNMP, but not enough. I need to develop an
I know very little about JavaScript but despite this I'm trying to cobble something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.