SA-MP Forums Archive
[INFO]Total users registred -> sql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [INFO]Total users registred -> sql (/showthread.php?tid=352684)



[INFO]Total users registred -> sql - TheBluec0de - 20.06.2012

how to calculate the total users registred, into the database ? i use BlueG MySQL Plugin


Re: [INFO]Total users registred -> sql - Pizzy - 20.06.2012

SELECT NULL FROM <userdb>

new tRows = mysql_num_rows();

tRows = How many users are in the <userdb>.


Re: [INFO]Total users registred -> sql - Mandrakke - 20.06.2012

pawn Код:
mysql_query("SELECT * FROM users");
new total_registered_users = mysql_num_rows();

edit: too late.


Re: [INFO]Total users registred -> sql - TheBluec0de - 20.06.2012

Thanks


Re: [INFO]Total users registred -> sql - TheBluec0de - 20.06.2012

exactly is this, correct ?

PHP код:
    format(querysizeof(query), "SELECT * FROM `%s`"TABLE_NAME);
    
mysql_query(query);
    
    
mysql_store_result();
    
    new
        
total_users mysql_num_rows();

    
mysql_free_result();

    print(
"-----------------------------------------------------------------------------");
    
printf("MySQL: The are %d users registred"total_users);
    print(
"-----------------------------------------------------------------------------\n"); 



Re: [INFO]Total users registred -> sql - TheBluec0de - 20.06.2012

bump


Re: [INFO]Total users registred -> sql - ReneG - 20.06.2012

Why would you select everything? A waste of memory.

pawn Код:
format(query, sizeof(query), "SELECT COUNT(*) FROM `%s`", TABLE_NAME);
    mysql_query(query);
   
    mysql_store_result();
   
    new
        total_users = mysql_fetch_int();

    mysql_free_result();
Or whatever function gets the integer from the field.


Re: [INFO]Total users registred -> sql - TheBluec0de - 20.06.2012

Quote:
Originally Posted by VincentDunn
Посмотреть сообщение
Why would you select everything? A waste of memory.

pawn Код:
format(query, sizeof(query), "SELECT COUNT(*) FROM `%s`", TABLE_NAME);
    mysql_query(query);
   
    mysql_store_result();
   
    new
        total_users = mysql_fetch_int();

    mysql_free_result();
Or whatever function gets the integer from the field.
Thanks