thinkphp±í¸ñÔõôºÏ²¢
thinkphp±í¸ñÔõôºÏ²¢£¿
ThinkPHPÊÇÒ»¿îÓÅÒìµÄ¿ªÔ´PHP¿ª·¢¿ò¼Ü£¬ËüµÄ¼òÆÓÒ×ÓᢸßЧÎȹ̡¢À©Õ¹ÐÔÇ¿µÈÌص㱸ÊÜ¿ª·¢ÕßµÄϲ»¶¡£ÔÚÏÖʵ¿ª·¢ÖУ¬±í¸ñÊǷǾ³£ÓõĹ¦Ð§£¬¶ø±í¸ñµÄºÏ²¢Ò²ÊÇÒ»¸ö³£¼ûµÄÐèÇó¡£
±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃThinkPHP¾ÙÐбí¸ñºÏ²¢µÄ²Ù×÷¡£
Ò»¡¢ºÏ²¢µ¥Î»¸ñ
Ôںϲ¢µ¥Î»¸ñ֮ǰ£¬ÐèÒªÏȹ¹½¨Ò»¸öÊý¾Ý±í¸ñ£¬ÈçÏ£º
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
<table> <tr> <th rowspan="2">ÐÕÃû</th> <th colspan="2">¿Î³Ì</th> <th rowspan="2">×Ü·Ö</th> </tr> <tr> <th>ÓïÎÄ</th> <th>Êýѧ</th> </tr> <tr> <td>ÕÅÈý</td> <td>90</td> <td>80</td> <td>170</td> </tr> <tr> <td>ÀîËÄ</td> <td>75</td> <td>85</td> <td>160</td> </tr> <tr> <td>ÍõÎå</td> <td>80</td> <td>75</td> <td>155</td> </tr> </table>
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸ö±í¸ñÖУ¬ÐèÒª½«µÚÒ»Áк͵ÚËÄÁеĵ¥Î»¸ñ¾ÙÐкϲ¢¡£Ê¹ÓÃThinkPHPµÄÊÓͼģ°å£¬¿ÉÒÔÕâÑùд£º
<table> <tr> <th rowspan="2">ÐÕÃû</th> <th colspan="2">¿Î³Ì</th> <th rowspan="2">×Ü·Ö</th> </tr> <tr> <th>ÓïÎÄ</th> <th>Êýѧ</th> </tr> <?php foreach($data as $k => $v):?> <tr> <?php if($k == 0):?> <td rowspan="<?=count($data)?>"><?=$v['name']?></td> <?php endif;?> <td><?=$v['chinese']?></td> <td><?=$v['math']?></td> <?php if($k == 0):?> <td rowspan="<?=count($data)?>"><?=$v['total']?></td> <?php endif;?> </tr> <?php endforeach;?> </table>
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸ö´úÂëÖУ¬Ê¹ÓÃÁËÒ»¸öforeachÑ»·£¬½«Êý¾Ýƾ֤Ðеķ½·¨Öð¸öÊä³ö¡£ÈôÊÇÊǵÚÒ»ÐеÄÊý¾Ý£¬Ôò½«µÚÒ»Áеĵ¥Î»¸ñÉèÖÃΪ¿çÐУ¬¿çÔ½µÄÐÐÊýÊÇÊý¾ÝµÄ×ÜÐÐÊý£»ÈôÊÇÊÇ×îºóÒ»ÐеÄÊý¾Ý£¬Ôò½«µÚËÄÁеĵ¥Î»¸ñÉèÖÃΪ¿çÐУ¬¿çÔ½µÄÐÐÊýͬÑùÊÇÊý¾ÝµÄ×ÜÐÐÊý¡£ÆäËûµÄµ¥Î»¸ñÖ±½ÓÊä³ö¶ÔÓ¦µÄÊý¾Ý¼´¿É¡£ÕâÑù¾Í¿ÉÒÔʵÏÖµ¥Î»¸ñµÄºÏ²¢ÁË¡£
¶þ¡¢ºÏ²¢±í¸ñ
³ýÁ˵¥Î»¸ñµÄºÏ²¢£¬ÓÐʱ»¹ÐèÒª½«¶à¸ö±í¸ñºÏ²¢³ÉÒ»¸ö´óµÄ±í¸ñ¡£Õâ¸öʱ¼ä¿ÉÒÔ½èÖúThinkPHPµÄÄ£°åÒýÇæÀ´ÊµÏÖ¡£¼ÙÉèÓÐÁ½¸öÊý¾Ý±í¸ñÈçÏ£º
±í¸ñÒ»£º
<table> <tr> <th>ÐÕÃû</th> <th>ÄêËê</th> </tr> <tr> <td>ÕÅÈý</td> <td>22</td> </tr> <tr> <td>ÀîËÄ</td> <td>23</td> </tr> <tr> <td>ÍõÎå</td> <td>24</td> </tr> </table>
µÇ¼ºó¸´ÖÆ
±í¸ñ¶þ£º
<table> <tr> <th>ѧ¿Æ</th> <th>Ч¹û</th> </tr> <tr> <td>ÓïÎÄ</td> <td>90</td> </tr> <tr> <td>Êýѧ</td> <td>80</td> </tr> <tr> <td>Ó¢Óï</td> <td>85</td> </tr> </table>
µÇ¼ºó¸´ÖÆ
ÕâÁ½¸ö±í¸ñ¶¼¿ÉÒÔʹÓÃÉÏÎÄÏÈÈݵÄÒªÁì¾ÙÐе¥Î»¸ñºÏ²¢¡£ÈôÊÇÐèÒª½«ÕâÁ½¸ö±í¸ñºÏ²¢³ÉÒ»¸ö´óµÄ±í¸ñ£¬¿ÉÒÔƾ֤ÈçÏ·½·¨¾ÙÐбàд£º
<table> <tr> <th>ÐÕÃû</th> <th>ÄêËê</th> <th colspan="2">Ч¹û</th> </tr> <tr> <td>ÕÅÈý</td> <td>22</td> <td>ÓïÎÄ</td> <td>90</td> </tr> <tr> <td>ÀîËÄ</td> <td>23</td> <td>Êýѧ</td> <td>80</td> </tr> <tr> <td>ÍõÎå</td> <td>24</td> <td>Ó¢Óï</td> <td>85</td> </tr> </table>
µÇ¼ºó¸´ÖÆ
Õâ¸ö´úÂëÖУ¬½«µÚÈýÁк͵ÚËÄÁеĵ¥Î»¸ñ¾ÙÐÐÁ˺ϲ¢£¬³ÉΪһ¸öеıí¸ñ¡£ÆäËûµÄµ¥Î»¸ñƾ֤ÔÀ´µÄ˳Ðò¾ÙÐÐÊä³ö¼´¿É¡£
Èý¡¢×ܽá
±¾ÎÄÏÈÈÝÁËʹÓÃThinkPHP¶Ô±í¸ñ¾ÙÐкϲ¢µÄÒªÁ졣ͨ¹ýµ÷½âµ¥Î»¸ñµÄrowspanºÍcolspanÊôÐÔ£¬¿ÉÒÔʵÏÖµ¥Î»¸ñµÄºÏ²¢£»Í¨¹ýÄ£°åÒýÇæµÄ¹¦Ð§£¬¿ÉÒÔ½«¶à¸ö±í¸ñºÏ²¢³ÉÒ»¸ö´óµÄ±í¸ñ¡£ÕâЩ¼¼ÇɹØÓÚÏÖʵ¿ª·¢Öеıí¸ñ²Ù×÷ºÜÊÇÓÐÓá£
ÒÔÉϾÍÊÇthinkphp±í¸ñÔõôºÏ²¢µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡