how to display data from mysql database into html table using php code example
Example 1: how to display data from mysql database into html table using php
Firstname |
Lastname |
";
while($row = mysqli_fetch_array($result))
{
echo "";
echo "" . $row['FirstName'] . " | ";
echo "" . $row['LastName'] . " | ";
echo "
";
}
echo "";
mysqli_close($con);
?>
Example 2: mysql data to html table
'; //initialize table tag
while ($property = mysqli_fetch_field($result)) {
echo '' . $property->name . ' | '; //get field name for header
array_push($all_property, $property->name); //save those to array
}
echo '
'; //end tr tag
//showing all data
while ($row = mysqli_fetch_array($result)) {
echo "";
foreach ($all_property as $item) {
echo '' . $row[$item] . ' | '; //get items using property value
}
echo '
';
}
echo "";
?>