Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php>>>html

// PHP code to establish connection
// with the localserver
<?php
  
// Username is root
$user = 'root';
$password = ''; 
  
// Database name is gfg
$database = 'gfg'; 
  
// Server is localhost with
// port number 3308
$servername='localhost:3308';
$mysqli = new mysqli($servername, $user, 
                $password, $database);
  
// Checking for connections
if ($mysqli->connect_error) {
    die('Connect Error (' . 
    $mysqli->connect_errno . ') '. 
    $mysqli->connect_error);
}
  
// SQL query to select data from database
$sql = "SELECT * FROM userdata ORDER BY score DESC ";
$result = $mysqli->query($sql);
$mysqli->close(); 
?>
// HTML code to display data in tabular format
<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <title>GFG User Details</title>
    <!-- CSS FOR STYLING THE PAGE -->
    <style>
        table {
            margin: 0 auto;
            font-size: large;
            border: 1px solid black;
        }
  
        h1 {
            text-align: center;
            color: #006600;
            font-size: xx-large;
            font-family: 'Gill Sans', 'Gill Sans MT', 
            ' Calibri', 'Trebuchet MS', 'sans-serif';
        }
  
        td {
            background-color: #E4F5D4;
            border: 1px solid black;
        }
  
        th,
        td {
            font-weight: bold;
            border: 1px solid black;
            padding: 10px;
            text-align: center;
        }
  
        td {
            font-weight: lighter;
        }
    </style>
</head>
  
<body>
    <section>
        <h1>GeeksForGeeks</h1>
        <!-- TABLE CONSTRUCTION-->
        <table>
            <tr>
                <th>GFG UserHandle</th>
                <th>Practice Problems</th>
                <th>Coding Score</th>
                <th>GFG Articles</th>
            </tr>
            <!-- PHP CODE TO FETCH DATA FROM ROWS-->
            <?php   // LOOP TILL END OF DATA 
                while($rows=$result->fetch_assoc())
                {
             ?>
            <tr>
                <!--FETCHING DATA FROM EACH 
                    ROW OF EVERY COLUMN-->
                <td><?php echo $rows['username'];?></td>
                <td><?php echo $rows['problems'];?></td>
                <td><?php echo $rows['score'];?></td>
                <td><?php echo $rows['articles'];?></td>
            </tr>
            <?php
                }
             ?>
        </table>
    </section>
</body>
  
</html>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel onclick all notification reads 
Php :: pivot null in livewire refresh 
Php :: post with count greater than 1 laravel 
Php :: remove elements to this array 
Php :: laravel route where not contain 
Php :: add reviews from code site reviews wp 
Php :: set session expire time in php 
Php :: how to concatenate folder name with image in php 
Php :: big database file into database php 
Php :: laravel timestamp not updating 
Php :: php prepared statement and conditional 
Php :: date format in php 
Php :: php: Güvenlik Fonksiyonu 
Php :: type of var php 
Php :: Josn_encode php api encoding issue 
Php :: Augmenter la dimension des fichiers WP 
Php :: PHP vprintf — Output a formatted string 
Php :: Breaking of code snippets in CKEditor as result code blocks are empty. 
Php :: php sort array 
Php :: apagar windows desde consola 
Php :: trying to change iframe location from javascript 
Php :: laravel command Retrieve a specific option 
Php :: omnipay refund 
Php :: extract date from datetime object in php 
Php :: cashier mollie 
Php :: PHP OOP - Class Constants 
Php :: laravel-filemanager showing blank page 
Php :: php get cosine sim 
Php :: larvael die and dump facade 
Php :: x-default wpml canonical alternate hreflang 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =