如何在嵌套while循环下运行mysqli“ select”查询?

时间:2019-04-30 08:42:26

标签: php mysqli

我正在尝试在mysqli查询的两个嵌套while循环之间执行“选择查询”,但是它不起作用。

Table Structure

Id  ArticleId   UserIp
----------------------
1    10       116.202.34.165
2    99       106.220.38.195  
3    10       116.202.34.165  
4    25       74.192.24.105  

上面有表结构

/*** Get All Unique IP Address List ***/
$userip=mysqli_query($dbcon,"select distinct(UserIp) from pageview where date between date_sub(now(), interval 30 day) and now()");

/*** Get All Unique Articles List ***/
$articleid=mysqli_query($dbcon,"select distinct(ArticleId) from pageview where date between date_sub(now(), interval 30 day) and now()");

/*** Fetch IP List ***/
while($iplist=mysqli_fetch_array($userip)){

/*** Fetch Article List ***/
    while($articlelist=mysqli_fetch_array($articleid)){
        $usrip= $iplist['UserIp'];
        $artid= $articlelist['ArticleId'];

    /*** Get Unique Visiter List ***/
        $unique_data= mysqli_query($dbcon,"select * from pageview where UserIp='$usrip' and ArticleId='$artid' ");

    }
}


我需要唯一身份访问者总数。 1)如果1个UserIp具有两次相同的商品ID,则我们必须将其排除在外,否则我们必须计算并打印总浏览量。

0 个答案:

没有答案