Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: swap image

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    swap image

    hi,

    i have a php script that checks that a domain is working, its effectivly a status page so i can check all the domains i have are working ok without visiting each site individually.

    The php script is:

    PHP Code:
    <?php

    $live 
    "live_green.gif";
    $dead "dead_red.gif";

    $link $_GET['link'].":";
    $s_link str_replace("::"":"$link);
    list(
    $addr,$port)= explode (':',"$s_link");
    if (empty(
    $port)){
        
    $port 80;
    }

    $churl = @fsockopen(server($addr), $port$errno$errstr20);
                 if (!
    $churl){
                
                    
    header("Location: $dead");
                    }
                 else {
                       
    header("Location: $live");             
              }
    function 
    server($addr){
             if(
    strstr($addr,"/")){$addr substr($addr0strpos($addr"/"));}
             return 
    $addr;
    }
    ?>
    and then i reference that through an image tag like so: <img src="status.php?link=www.microsoft.com">

    it then returns a green or red blob to show the status.

    the problem i have is with the large amount of domains, the page can take a while to load and the blobs dont appear instantly so i would like to show a little loading gif image whilst the blobs are loading, any ideas how to do this? i have seen it on a few sites but cant figure it out...

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Set a background image on the img tag. Make that a loading gif. Once it is loaded it will appear in all backgrounds and then be covered by the actual image.

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    perfect thankyou!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •