NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming > CODE
Reload this Page Random add Script

CODE This forum is for posting code snippets and example scripts that aren't quite tutorials, but could be useful for others. You may post code snippets and/or completed scripts that you've written and want to share here.

Advanced Search
7 members in live chat ~  


Closed Thread
 
LinkBack Thread Tools
Old 04-05-2006, 01:50 AM THREAD STARTER               #1 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV

Random add Script


Hi,

If you want a copy its nice and easy in php, just put where you want the ads to appear:
Code:
	<?php 
srand( microtime() * 1000000); 
$advertise = rand(1,3); 
//After the rand decided how many youve got and the first and last number e.g got 3, 1,3
switch($advertise) 
//you can add more just use the same format
{ 
case 1 : $banner="site 1 image url"; $url="site one address"; break; 
case 2 : $banner="site 2 image url"; $url="site two address"; break; 
case 3 : $banner="site 3 image url"; $url="site 3 address"; break; 
} 
$display = "<a href=\"$url\" target=\"_blank\"> "; 
$display.= "<img src=\"$banner\"  "; 
$display.= "width=\"468\" height=\"60\" border=\"0\" >"; 
$display.="</a>"; 
echo($display); 
?>
Thanks and enjoy.
????: NamePros.com http://www.namepros.com/code/183969-random-add-script.html

p.s (I Like rep )
Xyzer is offline  
Old 04-05-2006, 05:49 PM   #2 (permalink)
NamePros Regular
 
cvxdes's Avatar
Join Date: Oct 2005
Location: Milford MA
Posts: 689
cvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud ofcvxdes has much to be proud of
 



And if you want FlatDB, I just wrote this.

In your DB file, put:
Code:
http://www.hi.com||http://www.hi.com/hi.png
http://www.hi2.com||http://www.hi2.com/hi.png
The php:
PHP Code:
<?
funtion ad_template
($url$img){
    
$ad "<a href='".$url."'><img src='".$img."' alt=''/>";
????: NamePros.com http://www.namepros.com/showthread.php?t=183969
    return 
$ad;
}
$i 0;
$lines file('addb.txt');
foreach(
$lines as $line){
    
$i++;
    
$data explode("||"$line);
????: NamePros.com http://www.namepros.com/showthread.php?t=183969
    
$return[$i] = ad_template($data[0], $data[1]);
}
$number rand(0,$i);
echo 
$return[$number];
?>
cvxdes is offline  
Old 04-15-2006, 01:31 PM   #3 (permalink)
Resistance is Futile
 
Kadenz's Avatar
Join Date: Apr 2006
Location: Montreal, Canada
Posts: 1,094
Kadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to allKadenz is a name known to all
 



Wildlife Lou Gehrig's Disease (ALS)

That's a pretty useful script, I'll use it everywhere!
????: NamePros.com http://www.namepros.com/showthread.php?t=183969

Added Random Ad Sizes.
PHP Code:
<?php 
srand
microtime() * 1000000); 
$advertise rand(1,3); 
//After the rand decided how many youve got and the first and last number e.g got 3, 1,3
switch($advertise
//you can add more just use the same format

case 
$banner="site 1 image url"$url="site one address"$imgwidth="88"$imgheight="31"; break; 
case 
$banner="site 2 image url"$url="site two address"$imgwidth="50"$imgheight="50"; break; 
case 
$banner="site 3 image url"$url="site 3 address"$imgwidth="468"$imgheight="60"; break; 
????: NamePros.com http://www.namepros.com/showthread.php?t=183969

$display "<a href=\"$url\" target=\"_blank\"> "
$display.= "<img src=\"$banner\"  "
$display.= "width=\"$imgwidth\" height=\"$imgheight\" border=\"0\" >"
$display.="</a>"
echo(
$display); 
?>
__________________
Freelance Web Developer
PHP, MySQL, XHTML, CSS, Javascript, jQuery, Wordpress
Portfolio: www.bundy.ca
Last edited by Kadenz; 04-15-2006 at 01:47 PM.
Kadenz is offline  
Old 04-15-2006, 10:46 PM THREAD STARTER               #4 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
I could have added the sizes, ill do that on the next version that comes, out, cvxdes, i dont see what you are trying to do, break into my thread, mine is just a flat db, no mysql or anything involved.
Xyzer is offline  
Old 04-15-2006, 10:55 PM   #5 (permalink)
NamePros Legend
 
weblord's Avatar
Join Date: Dec 2005
Location: Philippines - www.Nabaza.com
Posts: 19,784
weblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatnessweblord Has achieved greatness
 


Autism Protect Our Planet
nice script, rep is coming your way.
__________________
Nabaza.com - Amaia
weblord is offline  
Old 04-15-2006, 11:11 PM THREAD STARTER               #6 (permalink)
Senior Member
 
Xyzer's Avatar
Join Date: Aug 2005
Location: United Kindom
Posts: 1,502
Xyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to allXyzer is a name known to all
 


Tsunami Relief AIDS/HIV
Oh, thanks! Its a script i needed to do something then when i learnt php, everyone is liking it.
Xyzer is offline  
Old 06-21-2006, 01:18 PM   #7 (permalink)
NP Maniacâ„¢
 
Phoenix's Avatar
Join Date: Apr 2004
Location: Nottingham, UK
Posts: 820
Phoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to beholdPhoenix is a splendid one to behold
 




Very nice, was looking for something like this a while ago ..!
__________________
PHP/MySQL Development offered: PM me for a quote.
47ideas.com - my freelancing portfolio.
Phoenix is offline  
Old 08-24-2006, 01:20 PM   #8 (permalink)
 
kleszcz's Avatar
Join Date: Jul 2006
Posts: 4,609
kleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatnesskleszcz Has achieved greatness
 



Marrow Donor Program Multiple Sclerosis
Simply basic but applicable to any object with modifications. Thanks.
kleszcz is offline  
Closed Thread


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


 
All times are GMT -7. The time now is 02:40 PM.

Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger