Search
 
SCRIPT & CODE EXAMPLE
 

PHP

json to html php table

/*Fetching JSON file content using php file_get_contents method*/
$str_data = file_get_contents("emp-records.json");
$data = json_decode($str_data, true);
 
/*Initializing temp variable to design table dynamically*/
$temp = "<table>";
 
/*Defining table Column headers depending upon JSON records*/
$temp .= "<tr><th>Employee Name</th>";
$temp .= "<th>Designation</th>";
$temp .= "<th>Company</th>";
$temp .= "<th>Mobile Number</th></tr>";
 
/*Dynamically generating rows & columns*/
for($i = 0; $i < sizeof($data["employees"]); $i++)
{
$temp .= "<tr>";
$temp .= "<td>" . $data["employees"][$i]["empName"] . "</td>";
$temp .= "<td>" . $data["employees"][$i]["designation"] . "</td>";
$temp .= "<td>" . $data["employees"][$i]["company"] . "</td>";
$temp .= "<td>" . $data["employees"][$i]["mob"] . "</td>";
$temp .= "</tr>";
}
 
/*End tag of table*/
$temp .= "</table>";
 
/*Printing temp variable which holds table*/
echo $temp;
Comment

PREVIOUS NEXT
Code Example
Php :: move_uploaded_file 
Php :: php error check 
Php :: max title limit woocommerce product 
Php :: laravel get data from request 
Php :: cors error angular php 
Php :: reset id auto increment after deleting a table row in phpmyadmin 
Php :: composer create new laravel project 
Php :: 413 error laravel 
Php :: showing from to in larvel pagination 
Php :: php lowercase assoc array 
Php :: how to make a comment in php 
Php :: install php pdo mysql PHP5.6 alpine-apache 
Php :: install php 7.1 on ubuntu 18.04 
Php :: laravel db drop table 
Php :: laravel update email unique 
Php :: how to call php function from ajax 
Php :: foreign key cosntraint laravel 
Php :: laravel get data in pivot table 
Php :: update laravel 
Php :: php split string 
Php :: create role spatie 
Php :: laravel e commerce full project 
Php :: magento2 get full details of order collection 
Php :: php define array first 10 number 
Php :: laravel validation string type 
Php :: how to make a child theme in wordpress 
Php :: Remove class from body tag in wordpress 
Php :: Cambiar la imagen por defecto en producto WooCommerce 
Php :: laravel post request page csrf disable 
Php :: generate fake name php 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =