[Help]Php code to show iframe every 25-30 visitors?

sk8tavou

Elite Member
Joined
Aug 28, 2011
Messages
1,797
Reaction score
1,435
Hello guys!
I want to iframe a link on my website but i want it to be visible every 25-30 visitors!
So something like to choose a random number from 1-25 and everytime the number is 9 to show the iframe on the page!

As i know nothing about php i have no idea how to do it!
Any help is appreciated
smile.png

Also my iframe code seems not to work so good so if anyone can provide a new one i will appreciate it a lot
smile.png


Thanks in advance!

Ps:i also posted this in jr vip forum but now i think its better to have more people to see it :)
 
A random number won't work for this. You'll have to store a running count in a text file or DB though. Pm me the details if u wasn't me to help!
 
Yeah. You need to keep trackof your visitors number and then do something like this:

if ($visitors_counter % 30 == 0) {
echo 'Your iframe code';
}

PS: You can store the IPs of the users and then count them. So you'll make sure that your iframe will show only for 30 unique visitors.
 
Last edited:
Thanks a lot both for the replies! But why a random number wont work?
if ($randomnumber == 9) {
echo 'Your iframe code';
}

again i dont know php so maybe my question seems silly :P
 
Because if $randomnumber is generated randomly(rand function) you don't know when your random generated number will be equal to 9.

PS: Added you on Skype.
 
Just started with php but I think something like this should work:


$randomNum = rand(1,30);
if ($randomNum == 9) {

iframe

}
 
Because if $randomnumber is generated randomly(rand function) you don't know when your random generated number will be equal to 9.

PS: Added you on Skype.

That's the whole point right? For a small amount of visitors the iframe could be active for more then 1 in 30, but as the visitor count increases it averages out to 1/30.
 
If you generate a random number every time some one his that page, it may never pick 9. Or it might pick 9, three times in a row.

That won't get your I frame showing up anywhere near once every 30 visits.
 
That's the whole point right? For a small amount of visitors the iframe could be active for more then 1 in 30, but as the visitor count increases it averages out to 1/30.

Thanks mate for your help! I worked with Xp3r7 and he made the code for me :)
 
Did you really have to crosspost the same question in 2 different places?
 
Here's the code: pastebin / AjwCy4Th (BHW filters don't allow me to post URLs)
Embed this code into your page.
You're welcome.
 
Back
Top