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
2
3
4
5
6
7
8
9
10
11
12
<?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 0, 1")); //Gets the newest member
echo "Newest User: " . $new[username]; //Displays the newest member
?>
Code split up
PHP Code
<?php
include("config.php");
Opens the php tags and includes our database connection.
PHP Code
$count = mysql_num_rows(mysql_query('SELECT * FROM `members`'));
Querys the members database and then counts the rows in the database.
Displays the number of rows in the database (How many members there are).
PHP Code
$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
echo "Newest User: " . $new[username];
?>
Shows the last member in the database and the end tag.
Updated by DanielXP