Findo Findo - 1 year ago 84
PHP Question

How to merge cells in php generated table?

I found the solution on this site for displaying a blank cell when the xml array is repeated, but I can't seem to find an answer to merging the blank cells.

This is what I'm getting:

This is what I'd like it to look like (in terms of the merged cells):

So my question is, how do I merge those cells - tell the previous cell to use a rowspan? (alternatively, is there a way to tell the empty cells to have no border?

Here is my code:

<?php if ($work_name !=$currentWork) { ?>
if ($name != $currentName) {

echo html_encode($name);

$currentName = $name;


if ($work_name !=$currentWork) {

echo html_encode($work_name);

else {

echo " ";
$currentWork = $work_name;


if ($role_attrs->name == $previousRole) {


else {
echo html_encode($role_attrs->name);


$previousRole = $role_attrs->name;


I hope that all makes sense!

Answer Source

alternatively, is there a way to tell the empty cells to have no border

It's much easier way, just add some class to empty cell (like <td class="empty"> </td> and style it in your css with td.empty { border-top:none; }

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download