VOOZH about

URL: https://www.geeksforgeeks.org/php/how-to-make-a-leaderboard-using-php/

⇱ How to make a leaderboard using PHP ? - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

How to make a leaderboard using PHP ?

Last Updated : 23 Jul, 2025

The purpose of this article is to make a simple program to create a leaderboard using PHP. Below is the implementation for the same using PHP.  The prerequisites of this topic are PHP/MySQL and the installment of Apache Server on your computer.

Approach:

Step 1: First we will create a HTML table using <table> tag defined by the <tr> tag for creating rows. It's just a simple HTML/CSS file. The only thing worth noting is that we are using the Bootstrap 4 CSS framework to give style to our page. You can use any other styling framework of your choice or write your own CSS if you want.

Step 2: Fetch data from SQL and display it using PHP.

Step 3: Create a MySQL database by following commands.

CREATE DATABASE leaderboard;
CREATE TABLE leaderboard(userName VARCHAR(30), marks INT(10));

Step 4: Insert some values into the database.

INSERT INTO leaderboard(userName,marks) VALUES('Devesh Pratap Singh',100);

Step 5: Close the table tag, body tag, and html tag. 

Step 6: Save this file as "index.php".

Step 7: Copy this file inside your xampp server in htdocs directory.

Step 8: Open phpMyAdmin or MySQL server on your computer.

Step 9: Open https://localhost/index.php into your web browser.

Output after execution:

👁 Image
Output produced after running
Comment
Article Tags: