Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 232
0 Users 7 Guests Online

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
1
2
<?php
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
2
echo "Newest User: " . $new[username];
?>
Shows the last member in the database and the end tag.

Updated by DanielXP
gbt91
Author:
Views:
2944
Rating:
Posted on Sunday 17th August 2008 at 08:36 PM
schorsch
schorsch
oh sorry limit3 edit to limit 5 :-)
Posted on Sunday 17th August 2008 at 08:35 PM
schorsch
schorsch
<?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
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
soz double post LoL cancel plz :S
Posted on Thursday 31st May 2007 at 03:40 PM
gbt91
gbt91
oops missed the page xD
Posted on Thursday 31st May 2007 at 03:39 PM
gbt91
gbt91
oops missed the page xD
Posted on Thursday 31st May 2007 at 03:38 PM
gbt91
gbt91
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
It works now. Thank you very much guys ;)
Posted on Wednesday 30th May 2007 at 07:37 PM
Diablosblizz
Diablosblizz
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
Sry, didn't know the tags XD

Here again in the tagbox ;)
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
include('config.php');

// Query database
$count_sql 'SELECT * FROM members';
$count_result mysql_query($count_sql);

//gets the number
$count mysql_num_rows($count_result);

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
?>