Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/252.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在循环中运行AdWords代码,但仅每2次显示一次_Php_Wordpress_Google Ads Api - Fatal编程技术网

Php 如何在循环中运行AdWords代码,但仅每2次显示一次

Php 如何在循环中运行AdWords代码,但仅每2次显示一次,php,wordpress,google-ads-api,Php,Wordpress,Google Ads Api,我正在WordPress中运行我的归档博客文章的循环。我想显示广告从Adwords每2博客文章 我尝试在循环中添加一个计数器,但我认为我使用的代码不正确,因为我根本看不到页面上出现的广告 这是我的密码: <?php $sql="select * from bbs_fight_schedule order by id DESC"; $i=0; // variable for counter $res=mysql_query($sql); while($ress=mysql_fetch_ar

我正在WordPress中运行我的归档博客文章的循环。我想显示广告从Adwords每2博客文章

我尝试在循环中添加一个计数器,但我认为我使用的代码不正确,因为我根本看不到页面上出现的广告

这是我的密码:

<?php $sql="select * from bbs_fight_schedule order by id DESC";
$i=0; // variable for counter 
$res=mysql_query($sql);
while($ress=mysql_fetch_array($res)){
$sqlsn=mysql_query("select * from bbs_fighter_profiles where id='$ress[1]'");
$reesn=mysql_fetch_array($sqlsn);
$f1=$reesn[1];
$sqlsn1=mysql_query("select * from bbs_fighter_profiles where id='$ress[2]'");
$reesn1=mysql_fetch_array($sqlsn1);
$f2=$reesn1[1]; 
?>
<div id="sch_hold"> 
//Blog post Excerpt here
</div>

//Calling Google Ads Here            
<?php 
$i++;
if(!$i%2) {
echo '<div>Google Ad Code Here</div>';
}
?>

<?php endwhile; // end of the loop. ?>

难怪您会遇到问题,php sql html汤添加了表,并且没有缩进。差不多unreadable@user574632不幸的是,我没有创建网站,我只是想添加谷歌广告代码。真是一团糟。我想验证我的php是否正常。这就是我所说的,这不管用吗$i++;如果(!$i%2){echo'Google Ad Code Here';}好的,我很同情你,我会看一看或移动增量:if($i%2){/}$i++