Questions about the number of users with different IP addresses

Source: Internet
Author: User
Tags ip number
The problem of obtaining the number of users with different IP addresses is to obtain the number of all different ip addresses in a table. The table name onlineip field name cannot obtain different ip addresses after the IP address is run, the number of identical IP addresses is also counted. I don't know where the problem is. The code is as follows: & lt ;? Php $ link_IDmysql_connect (& quot; localhost & quot;, & quot; root & quot;, & quot; 198600 & quot
The purpose is to obtain the number of all different ip addresses in a table,
Table name online

Ip field name: ip

Different IP addresses cannot be obtained after running, and the number of identical IP addresses is also counted. if you do not know where the problem is, solve it.


The code is as follows:


$ 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 );
?>


------ Solution --------------------
I don't quite understand what you mean
Select count (*), ip FROM online group by ip number of users with different IP addresses
------ Solution --------------------
Modified and run. No problem .. But in the code, the variable is srt and then str ..

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.