Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default PHP Add Google Ads...

    Hey,

    Im making a script & I wanna be able to output a google ad after say, 10 outputted database querys.

    How would I do this?

    Thanks, Lew.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    I'm not 100% sure I know what you're on about. Do you mean like, grabbing a bunch of rows at the same time and displaying them in a list or whatever, and then after every tenth one put an ad?
    If so, then add a counter to the loop that you're using to display the results (I assume you're using a loop anyway), then use modulus to check if the number is a multiple of 10, if it is, display the ad.

  3. #3
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    Im not using a for() loop, Im using while(). Isnt there a way to find out the amount of rows been outputed, then insert some code say after 10 rows have been outputted?

    Lew.
    Im not here to be loved, I love to be hated :-}


  4. #4
    Join Date
    Jun 2008
    Location
    United Kingdom
    Posts
    2,015
    Tokens
    568

    Latest Awards:

    Default

    Quote Originally Posted by LMS16 View Post
    Im not using a for() loop, Im using while(). Isnt there a way to find out the amount of rows been outputed, then insert some code say after 10 rows have been outputted?

    Lew.
    PHP Code:
    <?php

    $counter 
    1;

    while (
    $queryStuff)
    {
        
    // Display the results
        
    echo $stuff;

        
    // Check if number is a multiple of 10
        
    if ($counter 10 == 0)
        {
            echo 
    $adCode;
        }

        
    // Increase the counter
        
    ++$counter;

    }

    ?>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •