homepage Welcome to WebmasterWorld Guest from 54.196.197.153
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Showing ads only to 20% percent of visitors
basketmen




msg:4480467
 7:50 am on Jul 31, 2012 (gmt 0)

Hi guys, how to do this in a php file

Showing ads only to 20% percent of visitors. Or showing different ads to another 80% visitors

any way that can work, maybe using time intervals, like the visitors that visit the site at minute 0-12 only that show it, and visitors that visit the site at minute 13-59 is not. Or another methode

please help or share if you have, this should be easy enough and many people should need it, already googling it but still cant found it

 

jdilegge




msg:4480468
 8:16 am on Jul 31, 2012 (gmt 0)

You could use a text log counter and for each pageview add +1 and every 80 pageviews show an ad. Pretty fast and low load.

topr8




msg:4480470
 8:24 am on Jul 31, 2012 (gmt 0)

i'd say the quickest way would be to generate a random number between 1-5 for every page view, if the number is 1 then show the ads if it is anything else show the alternative ads.

httpwebwitch




msg:4480561
 1:16 pm on Jul 31, 2012 (gmt 0)

<?php
$percent = 0.2;

if (rand(0,100) < (100*$percent)){
// show ads
} else {
// something else
}

?>


like topr8 said. doing things proportionally is best done using a rand()

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved