Jump to content

[SOLVED] Count Register Users


Trium918

Recommended Posts

<?php
$result = mysql_query("SELECT COUNT(id) as num FROM yourtable");
$row = mysql_fetch_object($result);
echo "Registered Users: ".$row->num;
?>

 

There is an error.

 

Your table isn't called yourtable, have you changed that? Have you made a connection to the database before this? Is your primary index called id?

 

This is just an example on how you would accomplish what you want to do, not something you can copy and paste into your current code.

 

The most important part of what I posted is the query, it counts the rows and returns that number as column "num", but you must change the query to match your index names, and table name

Link to comment
Share on other sites

And the error is .... ?

 

You might want to structure things better so as to enable rational error display ... Change

 

$result = mysql_query("SELECT COUNT(id) as num FROM yourtable");

 

to:

$query = "SELECT COUNT(id) as num FROM yourtable";
$result = mysql_query($query) or die("Error: ". mysql_error(). " with query ". $query); // see if that helps

Link to comment
Share on other sites

What if I had there were a total of 100000

users. What what is the php function that will

display the total as 100,000?

This function simply counts the rows the database, as you add rows, the number returned will increase by the same amount.

Link to comment
Share on other sites

What if I had there were a total of 100000

users. What what is the php function that will

display the total as 100,000?

This function simply counts the rows the database, as you add rows, the number returned will increase by the same amount.

 

The comma is added automatically, correct?

Link to comment
Share on other sites

What if I had there were a total of 100000

users. What what is the php function that will

display the total as 100,000?

This function simply counts the rows the database, as you add rows, the number returned will increase by the same amount.

 

The comma is added automatically, correct?

 

No, you will need to use http://us.php.net/numberformat on the result

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.