根据其他查询语句计算单个查询的所有记录

时间:2016-06-22 20:17:41

标签: php mysql

所以我想根据其他查询语句从查询语句中计算所有记录。换句话说,我想从所有totalviewer

中的同一page计算我的所有userip

我会把代码

<?php
  // gets the user IP Address and the page adress name link
  $user_ip = $_SERVER['REMOTE_ADDR'];
  $pagenew = $_SERVER['REQUEST_URI'];    
  $check_ip = "select userip from pageview where page='$pagenew' and userip='$user_ip'";
  $query1 = mysqli_query($db_conx_count, $check_ip);
  if (!$check_ip || mysqli_num_rows($query1)>=1)
  {

  }
  else
  {
     // adauga o query
    $insertview = "INSERT INTO pageview (id, page, userip) values ('','$pagenew','$user_ip')";
    $query2 = mysqli_query($db_conx_count, $insertview);
    // updateaza query cu un nou user
    $updateview = "UPDATE pageview SET totalviewer = totalviewer+1 where page='$pagenew'";
    $query3 = mysqli_query($db_conx_count, $updateview);

  }
?>


  <?php
    $stmt = "SELECT totalviewer FROM pageview WHERE page='$pagenew'";
    $query_stmt = mysqli_query($db_conx_count, $stmt);
  ?>

  <div class="vizualizari">Vizualizări <?php echo mysqli_num_rows($query_stmt);?></div>
    <?php mysqli_close($db_conx_count);?> 

在db中的momemt是来自userip的更多查询以及来自其他人的其他userip在同一页面上

0 个答案:

没有答案