1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Random banners with priority

Discussion in 'PHP' started by earngate, Jan 28, 2015.

  1. #1
    We have 3 Ads forms
    1-Every Ad can Enable/Disable
    2-Every Ad has its priority from 0 to 10
    3-Every Ad may be Banners OR Html/Javascript code

    Need to create PHP code or function to do :
    1-If Ad is enabled run it
    2-run rotate banners depend on it's priority
    3-if Ad type is Banner >> show banner
    4-if Ad type is Html/Javascript code >> show Html/Javascript code

    Thanks
     
    Last edited: Jan 28, 2015
    earngate, Jan 28, 2015 IP
  2. sarahk

    sarahk iTamer Staff

    Messages:
    28,049
    Likes Received:
    4,362
    Best Answers:
    123
    Trophy Points:
    665
    #2
    So what are we discussing? The plan sounds good. How far into the implementation have you got?
     
    sarahk, Jan 28, 2015 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    This all sounds like a DB / filesystem rotate-script thingamajingy.
    You check the DB for enabled ads, then you chek for type and priority, and then you either load the file (banner) from the filesystem (no need to store that in the DB, just store a link to where it's stored) or the code from the DB, and adjust the display based on however you weigh the priority.
     
    PoPSiCLe, Jan 28, 2015 IP
  4. earngate

    earngate Well-Known Member

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    We used
    if header_banner_kind !=1 >> AD is Banner
    else header_banner_kind ==0 >> AD is Html code
    and we used this code but Ad that is Banner only shown

    <?php
    $r = rand(1, 3);
    if (!empty(Options('header_banner_' . $r .'')) && (Options('header_banner_kind' . $r .'')!=1)) ?>
    <a href="<?php echo $Options['header_banner_url_' . $r .'']; ?>">
    <img src="<?php echo $Options['header_banner_image_' . $r .'']['url'];?>" alt="<?php bloginfo('name')?>"></a>
    else
    echo Options('header_banner_html_' . $r .'');
    ?>
    and Main problem we can't stop disabled AD
    How can do that
     
    earngate, Jan 28, 2015 IP
  5. HolyRoller

    HolyRoller Well-Known Member

    Messages:
    552
    Likes Received:
    27
    Best Answers:
    1
    Trophy Points:
    150
    #5
    The system that I setup where I work adjusts based on how well an ad performs. So if one advert converts better than another, it shows that advert more, if it stops performing it starts showing less. It works on an adjustable rolling system using cron jobs to check the performance every 5 mins.

    The initially query in MySql pulls in a list of all the available ads and joins to the table showing their performance. It then randomly picks the links giving a much higher weighting to the highest performing adverts. Adverts that don't perform literally get sidelined for a period of time until the number of impressions for the last 48 hours drops below a threshold after which the advert gets a chance to display again.

    It is amazing how much impact it can have.
     
    HolyRoller, Jan 29, 2015 IP
  6. earngate

    earngate Well-Known Member

    Messages:
    102
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    Thanks for replies
    and now We need to write

    ###############################
    if (( dig('header_banner_kind_1') == 1) AND ((empty($dig['header_banner_image_1']['url']) OR (empty ($dig['header_banner_url_1']))))) $AD_weight_1 = 0;
    if (( dig('header_banner_kind_2') == 1) AND ((empty($dig['header_banner_image_2']['url']) OR (empty ($dig['header_banner_url_2']))))) $AD_weight_2 = 0;
    if (( dig('header_banner_kind_3') == 1) AND ((empty($dig['header_banner_image_3']['url']) OR (empty ($dig['header_banner_url_3']))))) $AD_weight_3 = 0;

    if (( dig('header_banner_kind_1') == 2) AND ((empty($dig['header_banner_html_1'])))) $AD_weight_1 = 0;
    if (( dig('header_banner_kind_2') == 2) AND ((empty($dig['header_banner_html_2'])))) $AD_weight_2 = 0;
    if (( dig('header_banner_kind_3') == 2) AND ((empty($dig['header_banner_html_3'])))) $AD_weight_3 = 0;
    ###############################

    how we can do it by loop, array or by function but in little code
     
    earngate, Feb 1, 2015 IP