Home  >  Article  >  Backend Development  >  获得不同IP用户数量的有关问题

获得不同IP用户数量的有关问题

WBOY
WBOYOriginal
2016-06-13 10:08:01830browse

获得不同IP用户数量的问题
目的是取得一个表内所有不同的ip数量,
表名 online

ip字段名:ip

运行后无法获得不同的IP,相同的IP数量也计数了,不知道问题出在哪,求解。


代码如下:


$link_ID=mysql_connect("localhost","root","198600");

mysql_query("set names 'gb2312'"); 

mysql_select_db("my_db"); 

$srt="select distinct ip FROM online ;";

$result=mysql_query($str, $link_ID); 

$rows=mysql_num_rows($result); 

echo $rows;


mysql_close($link_ID);
?>


------解决方案--------------------
不是很明白你的意思
SELECT COUNT(*),ip FROM online GROUP BY ip 这样能取不同IP的用户数
------解决方案--------------------
经修改,运行,没问题。。不过代码中那个变量一开始是srt后来变成str..

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn