我已使用此代码生成基本的广告轮换系统

I have used this code for generating a basic advertisement rotation system

我已经为 运行 广告系统创建了一个代码,该系统不断循环并从用户那里获得印象,但不幸的是它不起作用。 我无法设置循环广告所需的 Shown=0。 帮帮我

<?php
//Connection File

include'db.inc.php';
$query ="select advert_id,image from advertisement where UNIX_TIMESTAMP() < expires and shown=0 ORDER BY advert_id ASC LIMIT 1";

$ads= mysqli_query($con,$query);

while($ads_rows = mysqli_fetch_assoc($ads))
    {
        $advert_id = $ads_rows['advert_id'];
        $image = $ads_rows['image'];

        echo '<a href="go.php?advert_id='.$advert_id.'"><img src="'.$image.'"></a>';

        mysqli_query($con,"UPDATE advertisement SET shown=1, impression= 'impression'+1 where advert_id=$advert_id");
        $shown=mysqli_query($con,"select count(advert_id) from advertisement where shown=0");
        $Show=mysqli_fetch_assoc($shown);
        //I want to set shown=0 so that it will keep on  looping

        if(empty ($shown['COUNT(advert_id)']))
        {
            mysqli_query($con,"UPDATE advertisement set shown=0");
        }   
    } 
?>

您只是在您的条件下使用了错误的变量,这里是固定代码:

<?php
//Connection File

include'db.inc.php';
$query ="select advert_id,image from advertisement where UNIX_TIMESTAMP() < expires and shown=0 ORDER BY advert_id ASC LIMIT 1";

$ads= mysqli_query($con,$query);

while($ads_rows = mysqli_fetch_assoc($ads))
    {
        $advert_id = $ads_rows['advert_id'];
        $image = $ads_rows['image'];

        echo '<a href="go.php?advert_id='.$advert_id.'"><img src="'.$image.'"></a>';

        mysqli_query($con,"UPDATE advertisement SET shown=1, impression= 'impression'+1 where advert_id=$advert_id");
        $shown=mysqli_query($con,"select count(advert_id) from advertisement where shown=0");
        $Show=mysqli_fetch_assoc($shown);
        //I want to set shown=0 so that it will keep on  looping

        if(empty ($Show['COUNT(advert_id)']))//$Show instead of $shown
        {
            mysqli_query($con,"UPDATE advertisement set shown=0");
        }   
    } 
?>