php - 如何添加编号或项目符号?

标签 php mysql html

我想知道如何将项目符号编号放入表格中。下面我循环回显主要指南和子指南的列表。

例如:

1. major1
   a. sub1
   b. sub2
   c. sub3
2. major2
   a. sub1
   b. sub2
   c. sub3

something like that.

<table width="594" height="82" cellpadding="3" bordercolor="#999999">
    <tr>
      <td width="38" height="20" bgcolor="#333333" scope="col"><span class="style30"></span></td>
      <td width="234" bgcolor="#333333" scope="col"><div align="center" class="style31">Behavioral Guidelines</div></td>
      <td colspan="4" bgcolor="#333333" scope="col"><div align="left" class="style31">
          <div align="center">Style</div>
      </div></td>
      <td scope="col">&nbsp;</td>
    </tr>
    <?php while($row = mysql_fetch_array($result2)){?>
    <tr>
      <td height="24" valign="top" bgcolor="#FFFFCC"><div align="center" class="style7">Major</div></td>
      <td valign="top" bgcolor="#FFFFCC"><div align="left"><span class="style29"><?php echo $row['majorBg'];?></span></div></td>
      <td width="17" valign="top" bgcolor="#FFFFCC"><div align="center"><span class="style15"><?php echo $row['msg'];?></span></div></td>
      <td width="17" valign="top" bgcolor="#FFFFCC"><div align="center"><span class="style15"><?php echo $row['mct'];?></span></div></td>
      <td width="17" valign="top" bgcolor="#FFFFCC"><div align="center"><span class="style15"><?php echo $row['mch'];?></span></div></td>
      <td width="17" valign="top" bgcolor="#FFFFCC"><div align="center"><span class="style15"><?php echo $row['mad'];?></span></div></td>
      <td width="194" valign="top" bgcolor="#FFFFCC"><span class="style24"><a href="sub.php?major_id=<? echo $row['major_id']; ?>" class="style22" >+ add sub guidelines (optional)</a></span></td>
    </tr>
    <? $sqlCommand="select * from sub_guidelines where major_id =". $row['major_id'];
    $sql1 = mysql_query($sqlCommand) or die (mysql_error()); 
    while($row1 = mysql_fetch_array($sql1))
     {?>
    <tr>
      <td height="2"><div align="center"><span class="style7">Sub</span></div></td>
      <td height="2"><div align="left"><span class="style15"><?php echo $row1['subBg'];?></span></div></td>
      <td height="2" class="style15"><div align="center"><?php echo $row1['ssg'];?></div></td>
      <td height="2" class="style15"><div align="center"><?php echo $row1['sct'];?></div></td>
      <td height="2" class="style15"><div align="center"><?php echo $row1['sch'];?></div></td>
      <td height="2" class="style15"><div align="center"><?php echo $row1['sad'];?></div></td>
      <td height="2" class="style15"><div align="left"></div></td>
      <?php } ?>
    </tr>
    <?php } ?>
    <?php mysql_close($con) ?>
  </table>

结果是:

1. major1
     a. sub1
     a. sub2
     a. sub3
1. major2
     a. sub1
     a. sub2
     a. sub3

它们的主要和次要编号相同。

最佳答案

您可以使用以下 HTML 来完成此操作。根据需要调整 PHP 脚本以获得以下输出。

<ol>
    <li>major1
    <ol type="a">
        <li>sub1
        <li>sub2
        <li>sub3
    </ol>
    <li>major2
    <ol type="a">
        <li> sub1
        <li> sub2
        <li> sub3
    </ol>
</ol>

关于php - 如何添加编号或项目符号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8074166/

相关文章:

php - 如何使用 PHP MySQL 对列的值进行分组?

sql - MySQL - 计算两个日期时间之间的净时间差,同时排除休息时间?

python - 使用 BeautifulSoup 从表中提取某些列

html - 全屏背景,固定位置在正文上方和内容下方

php - 如何从基于其他行和列值的列中选择一个值?

javascript - JSON编码的数组,如何在jQuery中使用

javascript - 登录失败时不刷新

php - 选择所有值并对不同表中的字段值同时求和

php - 如何访问类中的PDO对象?

html - 内联 div 的自动高度