Welcome to Welcome to DNF.com™ - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars

If you are new to domains and looking to buy, sell and learn about domains then you have come to the right place. DNForum is the largest domain name community on the internet and continues to grow every day. There are over 105,000 domainers on DNForum doing everything from buying domains, selling domains, learning about domains and discussing domains. Take a minute and Register.

Register Today on DNForum IT'S FREE!

Results 1 to 6 of 6
  1. #1
    Platinum Lifetime Member

    Join Date
    Dec 2006
    Location
    Virginia
    Posts
    218
    DNF$
    204
    Bank
    0
    Total DNF$
    204
    Donate  

    Random html to appear?

    I want to create a block of html on my home page that is different each time someone refreshes the page. Something like how ads are displayed is what I want. So maybe just adding something like openads to my site would be best. How would you go about this?

  2. #2
    Country hopper
    katherine's Avatar
    Join Date
    Jul 2005
    Location
    Up north
    Posts
    7,171
    Country

    Iceland
    DNF$
    31,103
    Bank
    0
    Total DNF$
    31,103
    Donate  
    You can do that with a server-side language available on your server for example PHP. It can also be done in javascript provided it's enabled on the client browser (most of the time it is but not always. Also search engines do not have javascript capability and won't see the block).
    Do you have PHP or another language like ASP enabled on your server so I could build an example ?
    NameNewsletter.com - free lists of available domain names
    ZoneFiles.net (beta) - ccTLD and gTLD droplists

  3. #3
    Platinum Lifetime Member

    Join Date
    Dec 2006
    Location
    Virginia
    Posts
    218
    DNF$
    204
    Bank
    0
    Total DNF$
    204
    Donate  
    I have php, it's GoDaddy's linux Hosting.

  4. #4
    Country hopper
    katherine's Avatar
    Join Date
    Jul 2005
    Location
    Up north
    Posts
    7,171
    Country

    Iceland
    DNF$
    31,103
    Bank
    0
    Total DNF$
    31,103
    Donate  
    Here is one example:
    I assume you will keep the blocks of code in external files and have 5 pages numbered 1.html thru 5.html in the same directory (you can adapt the $files variable for your purpose).
    The script will pick one file at random and display the contents. That's it.
    PHP Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <?php
    srand
    ((float) microtime() * 10000000); // randomize seed - not needed starting from PHP 4.2.0 and up
    $files = array("1.html""2.html""3.html""4.html""5.html");
    $random_file array_rand($files); // pick one entry at random

    include ($files[$random_file]); // display contents of the selected file 
    ?>
    </body>
    </html>
    NameNewsletter.com - free lists of available domain names
    ZoneFiles.net (beta) - ccTLD and gTLD droplists

  5. #5
    DNF Addict
    jdk's Avatar
    Join Date
    Jul 2004
    Location
    Florida
    Posts
    7,077
    Country

    United States
    DNF$
    803
    Bank
    0
    Total DNF$
    803
    Donate  
    You can also do it from a text file or MySQL database.

  6. #6
    Gold Lifetime Member

    Join Date
    Feb 2009
    Posts
    1
    DNF$
    166
    Bank
    0
    Total DNF$
    166
    Donate  
    Kate, I am having the same question but the php is not working for me. I am not a php programmer and am not even sure if I am typing in the directories the correct way. And then also, can I just copy the php and place it between a div tag on an html page?

    Thanks.

Bookmarks

Posting Permissions

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

Domain name forum recommended by Domaining.com