Findo Findo - 1 month ago 5
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:

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

echo html_encode($name);
}

$currentName = $name;

?>
</td>


<td><i>
<?php
if ($work_name !=$currentWork) {

echo html_encode($work_name);
}

else {

echo " ";
}
$currentWork = $work_name;


?></i></td>

<td>
<?php
if ($role_attrs->name == $previousRole) {
continue;

}

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


}

$previousRole = $role_attrs->name;

?></td>
</tr>


I hope that all makes sense!

Answer

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; }

Comments