dongyirong3564
2012-05-21 03:52 阅读 22
已采纳

使用rowspan将数据从数据库调用到表中

I have table "Owner" in my database where one of the field (System) saved data from a textarea box.

Table Owner;

staf_id || name || system

Below is an example of input of the textarea box;

aimsweb
elearning
registration

The example shows that each line represent different types system. How am I going to call data from the system field to the table below?

table http://img546.imageshack.us/img546/1170/31920845.png

When it is called, the columns "Staf ID" and "Name" will increase its rowspan based on the input in the textarea. Is it possible to do that?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    duanchuiwen6694 duanchuiwen6694 2012-05-21 04:04

    In php you could use:

    $rows_in_text_area = explode( "
    ", $system );
    

    Which should give you the number of rows of text in the text area. From there it should be straight forward to use the $rows_in_text_area for the rowspan in the staff ID and name cells like this:

    <td rowspan="$rows_in_text_area">$name</td>
    
    点赞 评论 复制链接分享
  • douyong6589 douyong6589 2012-05-21 04:00

    "The example shows that each line represent different types system." - this is an example of bad table structure. You should have a new table System with the following columns (example: StaffID, System

    But if you want to use it this way and going back to your question:no it will not increase the rowspan. It will just make the System cell bigger. If you did not convert new line characters into
    not even that because text will display in a single row.

    点赞 评论 复制链接分享

相关推荐