Calculate percentage with PHP?

Could you help me please?

This is what I am working on!

We have 3 ads:

ID1 = 25%
ID2 = 50%
ID3 = 75%

Now each ad unit will be assigned an ID and each of them will store views!

I can’t figure how to shows them so that each of them will show depending on the percentage of views selected?

I mean the one with 75% has to how 3 times, 50% two times and 25% only one time!

You have to take their views and then somehow figure the way to do it I can’t make it work!

Well it depends, do you plan to show the ads as round robin structure?

If then all you need to do is to count each hit:
1 => ID1
2 => ID2
3 => ID2
4 => ID3
5 => ID3
6 => ID3
7 => ID1
8 => ID2
etc.

If this is a set structure that wont change, you can base which AD show when on math. But if you plan to change the ads, the percentage etc. It is better to handle the count by storage.

For example in a database, memcache etc. where you have a system that control which ad you showed last, and which to show next. Just keep in mind race conditions can happen in these systems, so store hits separately from the round robin, since it is possible that ID1 is shown two times on a row instead of one due to this.

Thanks buddy do you have any example of a simply ad script based on priority?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.