When developing a system it is necessary to display the database data in an appropriate way. using a dynamic table to display such data is one of the methods used. I will show you how to retrieve the data to the table using PHP. In php i have used the laravel framework where controllers and views are used. Here I will not be explaining about the laravel framework.
The code below is used to get the data set from the database and to pass it to the view.
public function DHProjects()
{
$presult = DB::table('projects')->get();
return View::make('Projects/DHProjects')->with ('projectsList', $presult);
}
get() is an inbuilt function in laravel where you get the data in the table that you pass. Here the table name is 'projects'. These data are passed to the view when creating it as 'projectsList'.
In the view add this code to insert the data in the dynamic table.
The '@foreach' is used to dispay the data row by row for all the data in the 'projectsList' passed by the controller. the ProjectID, ProjectTitle, DateCreated, DateOdEvent and ProjectManager are the field names in the table 'projects' in the database.
With the CSS styles the output can be seen as below.


No comments:
Post a Comment