Valuate Domain Names
DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars
HomeRegisterMembershipsGetting StartedDomain Tools Domain EbooksSEO Software Domain Resellers Advertise

Go Back   DNForum - Domain Sales, Domain Forum, Domain Appraisals, Domain Registrars > Content Development > Website Development and Design Discussion > Coding/Programming/Languages
Register Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old 11-27-2007, 02:15 AM   #1 (permalink)
Platinum Lifetime Member
No Avatar
 
Last Online: 07-19-2009 03:48 PM
iTrader: (6)
Join Date: Dec 2006
Posts: 218
DNF$: 260
Location: Virginia
Country:


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?
twells22 is offline   Reply With Quote
Sponsored Ads
Old 11-27-2007, 08:29 AM   #2 (permalink)
Missing in action
 
sdsinc's Avatar
 
Name: Kate
Last Online: Yesterday 06:58 PM
iTrader: (41)
Join Date: Jul 2005
Posts: 4,626
DNF$: 27,483
Location: front line
Country:


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 ?
__________________
VeryOldNames.com
sdsinc is offline   Reply With Quote
Old 11-27-2007, 11:29 AM   #3 (permalink)
Platinum Lifetime Member
No Avatar
 
Last Online: 07-19-2009 03:48 PM
iTrader: (6)
Join Date: Dec 2006
Posts: 218
DNF$: 260
Location: Virginia
Country:


I have php, it's godaddy's linux hosting.
twells22 is offline   Reply With Quote
Old 11-27-2007, 03:07 PM   #4 (permalink)
Missing in action
 
sdsinc's Avatar
 
Name: Kate
Last Online: Yesterday 06:58 PM
iTrader: (41)
Join Date: Jul 2005
Posts: 4,626
DNF$: 27,483
Location: front line
Country:


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>
__________________
VeryOldNames.com
sdsinc is offline   Reply With Quote
Old 11-27-2007, 03:36 PM   #5 (permalink)
jdk
DNF Addict
 
jdk's Avatar
 
Name: Doug
Last Online: Yesterday 12:48 PM
iTrader: (175)
Join Date: Jul 2004
Posts: 6,886
DNF$: 68,548
Location: Florida
Country:


You can also do it from a text file or MySQL database.
jdk is offline   Reply With Quote
Old 02-15-2009, 07:19 PM   #6 (permalink)
Gold Lifetime Member
No Avatar
 
Last Online: 02-15-2009 07:19 PM
iTrader: (0)
Join Date: Feb 2009
Posts: 1
DNF$: 10


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.
mateo129 is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:28 AM.
Copyright @2001-2009 DNForum.com