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

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

WBOY
Release: 2016-06-13 13:48:00
Original
828 people have browsed it

获得不同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..

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template