2014-12-22 01:18
浏览 60

在PHP / HTML页面中显示MySQL表计数[关闭]

I want to display the current amount of users registered in my database (it's called dalton) / the users are stored in a table in that database called simpleauth_players. It stores their name, hash, registerdate, logindate, and lastip.

I want to somehow use a PHP code that (logs me into the database) and displays the current amount of names in the database. So I can display a message like "Hey, there is currently 1,894 registered players!" inside of my HTML/PHP page. I'm kinda a novice it would be awesome if somebody could share the code and instructions.

My code:

$connection = mysql_connect('host', 'username', 'password');

$query = "SELECT * FROM simpleauth_players"; 
$result = mysql_query($query);
$registered = "SELECT COUNT(*) FROM dalton.tables WHERE simpleauth_players = 'name' and     TABLE_TYPE='BASE TABLE';

echo "$registered"; 


All of my information is down here! Database Server: Server: Localhost via UNIX socket Server type: MariaDB Server version: 5.5.39-MariaDB - Source distribution Protocol version: 10 Server charset: UTF-8 Unicode (utf8) Web Server: Apache Database client version: libmysql - mysqlnd 5.0.11-dev - 20120503 - $Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $ PHP extension: mysqli phpMyAdmin: Version information: 4.1.14

图片转代码服务由CSDN问答提供 功能建议

我想显示在我的数据库中注册的当前用户数量(称为dalton)/用户存储在 该数据库中名为simpleauth_players的表。 它存储了它们的名称,哈希,registerdate,logindate和lastip。

我想以某种方式使用PHP代码(将我登录到数据库中)并显示当前的名称数量 数据库。 所以我可以显示一条消息,例如“嘿,目前有1,894名注册玩家!” 在我的HTML / PHP页面内。 如果有人可以分享代码和说明,我会很新手。


  $ connection =  mysql_connect('host','username','password'); 
 $ query =“SELECT * FROM simpleauth_players”;  
 $ result = mysql_query($ query); 
 $ registered =“SELECT COUNT(*)FROM dalton.tables WHERE simpleauth_players ='name'和TABLE_TYPE ='BASE TABLE'; 
echo”$ registered“; \  n 

我的所有信息都在这里! Database Server: Server:Localhost via UNIX socket Server type:MariaDB Server version :5.5.39-MariaDB - 源代码发布 协议版本:10 服务器字符集:UTF-8 Unicode(utf8) Web服务器: Apache 数据库客户端版本:libmysql - mysqlnd 5.0.11-dev - 20120503 - $ Id: bf9ad53b11c9a57efdb1057292d73b928b8c5c77 $ PHP扩展名:mysqli phpMyAdmin:版本信息:4.1.14

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongman5539 2014-12-22 01:26

    Try this:

    $num_rows = mysql_num_rows($result);
    点赞 打赏 评论

相关推荐 更多相似问题