开发者

Can I use <br> or similar in <td> to avoid RowSpan?

I am using PHP to generate a report, which is basically a one line table.

However, if any of the fields reflect a memo then I would like to see multiple lines of memo text - wit开发者_如何学Goh line breaks of some kid - and not just the whole memo text as one long string.

I am using PHP to generate the HHTML. I did try replacing all '\r\n' with <br>, but that didn't work.

To do it 'properly' is going to get messy. I need to examine all fields in the table and find the memo field with the most line breaks, then use the number of lines to add a rowspan to each<td> in the table.

Is there any easy way to avoid that?

Bad ascii art clarification follows. I currently have

-----------------------------------------------------------------------------------
| edit box text | radio group selection | memo line 1 memo line 2 ... memo line x | 
-----------------------------------------------------------------------------------

and what I want is:

------------------------------------------------------
| edit box text | radio group selection | memo line 1 |
|               |                       | memo line 2 | 
|               |                       |    ...      | 
|               |                       | memo line x | 
-------------------------------------------------------


what about do it like this:

<table>
  <tr>
    <td>edit box text</td>
    <td>radio group selectio</td>
    <td>
      <div>
        memo line 1
      </div>
      <div>
        memo line 2
      </div>
      <div>
        memo line 3
      </div>
    </td>
  </tr>
</table>

combining tables with div like this , you kept your table and forced the "memo"s to take a new line, and using this formation, you can give the memos a different styles.


Maybe this is over simplifying it, but why don't you just assign a fixed width to the table cell with the memo? I forget if <td>s can act funny with width set, but if so just wrap it in a div with fixed width.

OR with php...

wordwrap() — Wraps a string to a given number of characters

OR with CSS or a <pre> tag if it's already formatted:

td.has_memo {
    white-space:pre;
}

OR again, with php if it's preformatted:

nl2br() — Inserts HTML line breaks before all newlines in a string


Simply clear the formatting (if any) on the cell that needs to show the memo field.

Then print out the contents like this:

echo nl2br($Fields["MemoField"]);

The above function auto-converts all \n lines to br tags.

Hope this helps.


maybe this might work

<td valign="top">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜