Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to display data from mysql database into html table using php

<?php
$con=mysqli_connect("example.com","peter","abc123","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM Persons");

echo "<table border='1'>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['FirstName'] . "</td>";
echo "<td>" . $row['LastName'] . "</td>";
echo "</tr>";
}
echo "</table>";

mysqli_close($con);
?>
Comment

how to display sql database data in php

<?php
    $dbServername = "localhost";
    $dbUsername = "root";
    $dbPassword = "";
    $dbName = "dbname";
    
    $conn = mysqli_connect($dbServername, $dbUsername, $dbPassword, $dbName);
	
    $sql = "SELECT * FROM dbname;";
    $result = mysqli_query($conn, $sql);
    $resultCheck = mysqli_num_rows($result);

    if ($resultCheck > 0) {
      while ($row = mysqli_fetch_assoc($result)) {
        echo $row['sql_row_name'] . "<br>";
      }
    }
?>
Comment

display data from sql database with php

<?php
$host = "127.0.0.1"; //IP of your database
$userName = "root"; //Username for database login
$userPass = ""; //Password associated with the username
$database = "example-database"; //Your database name

$connectQuery = mysqli_connect($host,$userName,$userPass,$database);

if(mysqli_connect_errno()){
    echo mysqli_connect_error();
    exit();
}else{
    $selectQuery = "SELECT * FROM `tbl_users` ORDER BY `user_id` ASC";
    $result = mysqli_query($connectQuery,$selectQuery);
    if(mysqli_num_rows($result) > 0){
    }else{
        $msg = "No Record found";
    }
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>HTML and PHP code</title>
</head>
<body>
    <h1>Display user list using HTML and PHP</h1>
    <?=$msg;?>
    <table border="1px" style="width:600px; line-height:40px;">
        <thead>
            <tr>
                <th>Name</th>
                <th>Email</th>
                <th>Status</th>
                <th>Registrating Date</th>
            </tr>
        </thead>
        <tbody>
            <?php
                while($row = mysqli_fetch_assoc($result)){?>
                <tr>
                    <td><?php echo $row['user_firstName'].$row['user_lastName']; ?></td>
                    <td><?php echo $row['user_email']; ?></td>
                    <td><?php if($row['user_status'] == 1){
                        echo "Active";
                    }else{
                        echo "Deactive";
                    } ?></td>
                    <td><?php echo $row['user_registrationDate']; ?></td>
                <tr>
            <?}?>
        </tbody>
    </table>
</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Php :: php get ip by domain 
Php :: php check if its a name 
Php :: run artisan command from controller 
Php :: psicopata narcisista 
Php :: take fraction of number in laravel 
Php :: php get precent price 
Php :: php delete item from array 
Php :: php remove class attribute 
Php :: create array from string with commas php 
Php :: php remove wordpress shortcodes 
Php :: laravel read origanl value before update 
Php :: redaxo mform 7 
Php :: how to add extra days from a date php 
Php :: php 6 digit random number 
Php :: how to link external php file to html 
Php :: laravel create table with model command line 
Php :: codeigniter set timezone 
Php :: Turning a StdClass object into an array 
Php :: jetstream seed user with team 
Php :: php convert number to month 
Php :: errno: 150 foreign key constraint is incorrectly formed laravel 8 
Php :: if button is clicked php 
Php :: php get last index end in foreach 
Php :: how to get video duration in php 
Php :: laravel public access inserver using htaccess 
Php :: codeigniter query builder order by 
Php :: convert json object to array in php 
Php :: php set x-frame-options 
Php :: php date fomat 
Php :: remove cookies php 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =