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

Solutions on MaxInterview for how to display data from mysql database into html table using php by the best coders in the world

showing results for - "how to display data from mysql database into html table using php"
Monte
29 Jan 2017
1<?php
2$con=mysqli_connect("example.com","peter","abc123","my_db");
3// Check connection
4if (mysqli_connect_errno())
5{
6echo "Failed to connect to MySQL: " . mysqli_connect_error();
7}
8
9$result = mysqli_query($con,"SELECT * FROM Persons");
10
11echo "<table border='1'>
12<tr>
13<th>Firstname</th>
14<th>Lastname</th>
15</tr>";
16
17while($row = mysqli_fetch_array($result))
18{
19echo "<tr>";
20echo "<td>" . $row['FirstName'] . "</td>";
21echo "<td>" . $row['LastName'] . "</td>";
22echo "</tr>";
23}
24echo "</table>";
25
26mysqli_close($con);
27?>
28
Waylon
14 Jun 2019
1<?php
2$host    = "localhost";
3$user    = "username_here";
4$pass    = "password_here";
5$db_name = "database_name_here";
6
7//create connection
8$connection = mysqli_connect($host, $user, $pass, $db_name);
9
10//test if connection failed
11if(mysqli_connect_errno()){
12    die("connection failed: "
13        . mysqli_connect_error()
14        . " (" . mysqli_connect_errno()
15        . ")");
16}
17
18//get results from database
19$result = mysqli_query($connection,"SELECT * FROM products");
20$all_property = array();  //declare an array for saving property
21
22//showing property
23echo '<table class="data-table">
24        <tr class="data-heading">';  //initialize table tag
25while ($property = mysqli_fetch_field($result)) {
26    echo '<td>' . $property->name . '</td>';  //get field name for header
27    array_push($all_property, $property->name);  //save those to array
28}
29echo '</tr>'; //end tr tag
30
31//showing all data
32while ($row = mysqli_fetch_array($result)) {
33    echo "<tr>";
34    foreach ($all_property as $item) {
35        echo '<td>' . $row[$item] . '</td>'; //get items using property value
36    }
37    echo '</tr>';
38}
39echo "</table>";
40?>
41
queries leading to this page
get something from mysql php and displaydisplay mysql data in html tablephp code to retrieve data from mysql database and display in html tablemysql database data print in html phphow do i print database on html pagedisplay data from database using phpdisplay data from a mysql database in a html table using php data display in html table using php 26 mysqldisplay data from database in php in tabledisplay from mysql table in phpphp display data from database and show in tableshow mysql table data in htmldisplay data from database in table using phpsave html table data to mysqlphp display data from mysql tablehow to display data from database in php in tablephp script to display data from databasedisplaying data from database in phpshow data from database in phpphp display mysql records in htmlhow to display data from db in phpget data from database and display in html table in php and sqldisplay data in table from database in phpdifferent ways of display mysql data on phpdisplay php table from dbhow to display data from mysql database in phphow to display data in html from mysql in phpsimple php table display data in mysqldisplay data from database in php with htmlhow to display elements in a data from a database in html and phptable mysql to htmlphp mysql displaying data from tablephp code that access database and display results in tabledisplay sql database phpdisplay database mysql php tablephp display data from databasephp table in display records of mysqlhow to display database table in form phpdisplay database table in phpshow data from database in php in tablesdisplay data from mysql to html tablephp display table data from databasehow to display the data from the database in phphow to display data from mysql database into html table using php 282020 29show data from database on table phpdisplay sql data in tables in phpconvert html table to mysql databasemysql to html tablehow to display the entire table of database in phpshow data from mysql table using phpphp display items from databaseshow data in html table from mysql database using phpphp code to display database as html tabledisplay all data from database in phpmysql table to htmlhow to get data for database using php then display on htmlphp code for displaying data from database in a tableprint data from database in phphow to display mysql data in phphow to display all data from database in php in tablehow to display a database table in phpshow data from mysql table phphow to display data from database using phpshow data mysql phpdisplay table from database in phpconvert mysql table to htmlhow to display database values in table using phphow to display data from mysql database into html table using phpshow database data in table in phpmysql data to html tablehow to display data from database in html table in phpdisplay sql data in html table phpdisplay database data in phphow to display data from database in phpdisplay data in php from databasephp display data from database to tablehow to display data from the database as it is with phphow to get data from database in php and show in tablehow to display data in mysql database using html and phpload row from phpmyadmin in html tablehow to display database table in html page using phpphp display data from database in tablehow to display database table in phpgetting data from mysql table and displayin it in phphow to display table and records from mysql using phphow to display data from database to table in phpphp show mysql table in html how display data from database in phpdisplay data from database in html table using phpdisplay data from mysql database into html table using phpphp display table from mysqldisplay database data in htmlhow to display data from database in php in table formathow to get and display data on mysql database using phphow to display the data from database in html using phphow to view mysql database table in phpdisplay data from database in phphow to display database table data on webpage using phphow to display data from mysql database into html table using php