Active members

php code to display the Total Members of my website on my homepage?

this section is meant for posting code snippets then discussions around them.

But essentially all you need to do is count all the rows of your members table for that.

[php]//make a connection to your database

//get all members from the databade
$sql = mysql_query(“SELECT userID FROM table”);

//count all results
$n = mysql_num_rows($sql);

//print message and numbers
echo “Total members: $n”;[/php]

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Total members:

I had to try 50 different code, there is no one that works. o_O

did you replace the userID with the id of your table and also replace table with the name of your table?

no, I have no idea where to put this information.

I am a beginner in the field.

Ok do you know what system is powering your website I’m assuming it’s an open source cms that you’ve used.

i don’t know.
i’m with hostgator, this is my website ; ntraffics.com

had a look don’t know what system the site uses, if you’ve got cpanel access you can go to phpmyadmin once loaded you will be able to see all the database tables being used for that site’s database look for a table with accounts or members or users in the name chances are that’s the right one.

If this can help, I have a code in my admin section, which shows me the total of my users.

I just want transfer this code in my home page, but the code don’t work

<? //Limito la busqueda $TAMANO_PAGINA = 50; //examino la página a mostrar y el inicio del registro a mostrar $pagina = limpiar($_GET["pagina"]); if (!$pagina) { $inicio = 0; $pagina=1; } else { $inicio = ($pagina - 1) * $TAMANO_PAGINA; } $tabla = mysql_query("SELECT * FROM tb_users ORDER BY id ASC limit $inicio,$TAMANO_PAGINA"); // selecciono todos los registros de la tabla usuarios, ordenado por nombre while ($registro = mysql_fetch_array($tabla)) { // comienza un bucle que leera todos los registros y ejecutara las ordenes que siguen echo " ". $registro["id"] ." <== HERE<== HERE thx!

ok don’t know if these are right details but give this a try:

[php]//make a connection to your database

//get all members from the databade
$sql = mysql_query(“SELECT id FROM tb_users”)or die(mysql_error());

//count all results
$n = mysql_num_rows($sql);

//print message and numbers
echo “Total members: $n”;[/php]

daveismyname… Thank you so much for the php code you provided for Davez. I had the same question Davez had.

Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service