How to Make Automatic Merge Cells Using PHP

irnanto.com – cell merge function is combining two or more cells into one in a table. In HTML, combining the two into a single cell or a “two cells merge into one” there are two types of colspan and rowspan. Merge cells colspan used to combine two or more columns into one and merge cells rowspan used for auto-merge two or more lines into one.

Merge cells are often used in Microsoft Office applications such as Microsoft Office Word and Microsoft Office Excel to combine two or more cells into one in a table. This time irnanto.com discusses the use merge cells in an HTML table, especially the appearance of dynamic data using PHP, for which data is manipulated if the same will be made appearance in the HTML table into cells merge.

To create a table or display table from the database using the format merge cells in cell specific table then it would be nice if we look at the example html table merge cells below as an illustration how to display dynamic data from a database using PHP.

Table merge cells

The above table is a table that has been in the merged cell. But before in the merged cells, the data is shown as below

Instansi

Kegiatan

Anggaran

Dinas A

Kegiatan A

400.000

Dinas A

Kegiatan B

300.000

Dinas A

Kegiatan C

420.000

Dinas B

Kegiatan D

401.000

Dinas B

Kegiatan E

500.000

Dinas C

Kegiatan F

600.000

Dinas C

Kegiatan G

700.000

Dinas C

Kegiatan H

8.800.000

How to create a merge cells

The previously mentioned types of cells merge HTML to combine two cells into one. Example HTML script merge cells taken from the use rowspan in the first table and script as below.

Ok, we’ve seen the results of the appearance of the model script data in the table that has been in the merged cell, this time how to create a PHP script that can automatically adjust the display data of the same data in order to make the merge table cell. PHP script merge table cells as below.

Explanation script briefly above is the data that is captured from a database stored in a variable row. Calculate the amount of each twin data (name of institution), create tables and display the data in the previous iteration in check first to make rowspan merge table cells.

So the discussion on How to Make Automatic Merge Cells Using PHP, next time in the continued again with other interesting articles