数据特殊显示``````
将列表侧立,下面是效果图:
下面是实现方法:
<style> td { text-align:center; font-size: 12px; line-height: 20px; } .style1 { background-color: #D4AC89; margin-right:1px; color:#FFFFFF; font-weight: bold; } .style2 { color: #676767; } </style>
<?php //连接并选择到数据库服务器 $connection = mysql_connect ("localhost", "root", "mmmmmm"); mysql_select_db("test", $connection); //查询数据 mysql_query("SET NAMES 'utf-8'"); $query="SELECT shi FROM testtb group by shi"; $result=mysql_query($query,$connection); //mysql_fetch_array()获得数据,并输出 ?> <table cellpadding="0" cellspacing="0"> <tr> <? while($row=mysql_fetch_array($result)){?> <td width="100" valign="top"><div class="style1"><?=$row[0]?></div> <? $query1="SELECT sheng FROM testtb where shi='".$row[0]."'"; $i=0; $result1=mysql_query($query1,$connection); while($row1=mysql_fetch_array($result1)) { ?> <div class="style2" style="background-color: <? if ($i==1) {$i--;echo "#F3F3F3";} else {$i++;} ?>"> <?=$row1[0]?></div> <? }?> </td> <? }?> </tr> </table>
数据特殊显示``````