Newest & Total Members


This is the code for RMB-Scripting User System.

This script shows how many members there are in the database and the last member in the database.

PHP Code
  1. <?php
  2. include("config.php");
  3.  
  4. //Query database & Counts the rows in the members database
  5. $count = mysql_num_rows(mysql_query('SELECT * FROM `members`'));
  6.  
  7. echo $count; //Displays the total members
  8.  
  9. $new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1")); //Gets the newest member
  10. echo "Newest User: " . $new[username]; //Displays the newest member
  11. ?>


Code split up

PHP Code
  1. <?php
  2. include("config.php");
Opens the php tags and includes our database connection.

PHP Code
  1. $count = mysql_num_rows(mysql_query('SELECT * FROM `members`'));
Querys the members database and then counts the rows in the database.

PHP Code
  1. echo $count;
Displays the number of rows in the database (How many members there are).

PHP Code
  1. $new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1"));
Querys and fetchs the members database.
DESC is the order type (descending) what gets the last results to display first and the new ones last. Then limit only allows 1 result, Which is our last member.

PHP Code
  1. echo "Newest User: " . $new[username];
  2. ?>
Shows the last member in the database and the end tag.

Updated by DanielXP
gbt91's Avatar
Author:
Views:
3,197
Rating:
Posted on Sunday 17th August 2008 at 08:36 PM
schorsch
schorsch's Avatar
oh sorry limit3 edit to limit 5 :-)
Posted on Sunday 17th August 2008 at 08:35 PM
schorsch
schorsch's Avatar
<?php
include("config.php");

//Query database & Counts the rows in the members database
$count = mysql_num_rows(mysql_query('SELECT * FROM `members`'));

echo $count; //Displays the total members

$new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 3")); //Gets the 5 newest member
echo "Newest User: " . $new[username]; //Displays the newest member
?>
Posted on Sunday 17th August 2008 at 05:03 PM
jambomb
jambomb's Avatar
How can i show about 5 newest members ?? is that possible ?

plz comment back :)
Posted on Thursday 31st May 2007 at 03:40 PM
gbt91
gbt91's Avatar
soz double post LoL cancel plz :S
Posted on Thursday 31st May 2007 at 03:40 PM
gbt91
gbt91's Avatar
oops missed the page xD
Posted on Thursday 31st May 2007 at 03:39 PM
gbt91
gbt91's Avatar
oops missed the page xD
Posted on Thursday 31st May 2007 at 03:38 PM
gbt91
gbt91's Avatar
he means that you must control if the table is 'members' or else
Posted on Wednesday 30th May 2007 at 09:41 PM
MCP
MCP's Avatar
It works now. Thank you very much guys ;)
Posted on Wednesday 30th May 2007 at 07:37 PM
Diablosblizz
Diablosblizz's Avatar
For the way I made it, it was for members, but I guess gbt changed it.

Either way if you change the users to members and you are using RMB-scriptings member system.
Posted on Wednesday 30th May 2007 at 07:18 PM
Phoenixx
Phoenixx's Avatar
Sry, didn't know the tags XD

Here again in the tagbox ;)
PHP Code
  1. <?php
  2. include('config.php');
  3.  
  4. // Query database
  5. $count_sql = 'SELECT * FROM members';
  6. $count_result = mysql_query($count_sql);
  7.  
  8. //gets the number
  9. $count = mysql_num_rows($count_result);
  10.  
  11. echo"$count"; // displays the total members
  12.  
  13. $new = mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1")); // Gets the newest member
  14. echo "Newest User: " . $new[username]; // displays the newest member
  15. ?>