View Full Version : PHP Add Google Ads...
LMS16
22-02-2011, 12:28 PM
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.
Trinity
22-02-2011, 02:11 PM
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.
LMS16
22-02-2011, 04:26 PM
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.
Trinity
22-02-2011, 11:32 PM
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
$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;
}
?>
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.