<small id='LLQGc'></small><noframes id='LLQGc'>

  • <tfoot id='LLQGc'></tfoot>

  • <legend id='LLQGc'><style id='LLQGc'><dir id='LLQGc'><q id='LLQGc'></q></dir></style></legend>
    <i id='LLQGc'><tr id='LLQGc'><dt id='LLQGc'><q id='LLQGc'><span id='LLQGc'><b id='LLQGc'><form id='LLQGc'><ins id='LLQGc'></ins><ul id='LLQGc'></ul><sub id='LLQGc'></sub></form><legend id='LLQGc'></legend><bdo id='LLQGc'><pre id='LLQGc'><center id='LLQGc'></center></pre></bdo></b><th id='LLQGc'></th></span></q></dt></tr></i><div id='LLQGc'><tfoot id='LLQGc'></tfoot><dl id='LLQGc'><fieldset id='LLQGc'></fieldset></dl></div>

      <bdo id='LLQGc'></bdo><ul id='LLQGc'></ul>

        排列成每行 5 个单元格的表格

        时间:2023-10-04

              <small id='AarRk'></small><noframes id='AarRk'>

              <i id='AarRk'><tr id='AarRk'><dt id='AarRk'><q id='AarRk'><span id='AarRk'><b id='AarRk'><form id='AarRk'><ins id='AarRk'></ins><ul id='AarRk'></ul><sub id='AarRk'></sub></form><legend id='AarRk'></legend><bdo id='AarRk'><pre id='AarRk'><center id='AarRk'></center></pre></bdo></b><th id='AarRk'></th></span></q></dt></tr></i><div id='AarRk'><tfoot id='AarRk'></tfoot><dl id='AarRk'><fieldset id='AarRk'></fieldset></dl></div>
                <tbody id='AarRk'></tbody>

              • <tfoot id='AarRk'></tfoot>
                  <bdo id='AarRk'></bdo><ul id='AarRk'></ul>
                • <legend id='AarRk'><style id='AarRk'><dir id='AarRk'><q id='AarRk'></q></dir></style></legend>
                  本文介绍了排列成每行 5 个单元格的表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何将数组中的每个项目放入每行 5 个单元格或每列 5 列且没有行数限制的表格中.

                  How can I put each item in an array into a table with 5 cells in each row or 5 columns and no limit on how many rows there are.

                  这是我的代码:

                  if (mysql_num_rows($badgedata) <= 0)
                  {
                    $badge = "I have no badges =(";
                  }
                  else
                  {
                    // Sets the array for the badges
                    while($row = mysql_fetch_array($badgedata))
                    {
                      $badges[$row['badge_id']] = $row;
                    }
                    echo "<table><tbody>";
                    // Displays the badges in the array
                    foreach($badges as $badge => $id)
                    {
                      // I need the table here
                      echo "<img src="http://habbome.com/r63/c_images/album1584/$badge.gif" />";
                    }
                  }
                  

                  推荐答案

                  你只需要 echo 之前/每五个单元格之后:

                  You just need to echo <tr> and </tr>'s before/after every fifth cell:

                  $field = 0; // init field counter
                  echo "<table><tbody>";
                  // Displays the badges in the array
                  foreach($badges as $badge => $id)
                  {
                      if ($field % 5 == 0) echo '<tr>'; // start line before field 0 .. 5 .. 10 etc.
                      echo "<td><img src="http://habbome.com/r63/c_images/album1584/$badge.gif" /></td>"; // output as table cell
                      if ($field % 5 == 4) echo '</tr>'; // end line alter field 4 .. 9 .. 14 etc.
                      $field++; // increase field counter
                  }
                  if ($field % 5 != 0) echo '</tr>'; // close last line, unless total count was multiple of 5
                  echo "</tbody></table>";
                  

                  这篇关于排列成每行 5 个单元格的表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:将 HTML 表格另存为图像 下一篇:来自爆炸数组的 PHP 表

                  相关文章

                  最新文章

                  <i id='PE0kI'><tr id='PE0kI'><dt id='PE0kI'><q id='PE0kI'><span id='PE0kI'><b id='PE0kI'><form id='PE0kI'><ins id='PE0kI'></ins><ul id='PE0kI'></ul><sub id='PE0kI'></sub></form><legend id='PE0kI'></legend><bdo id='PE0kI'><pre id='PE0kI'><center id='PE0kI'></center></pre></bdo></b><th id='PE0kI'></th></span></q></dt></tr></i><div id='PE0kI'><tfoot id='PE0kI'></tfoot><dl id='PE0kI'><fieldset id='PE0kI'></fieldset></dl></div>
                • <tfoot id='PE0kI'></tfoot>

                      <bdo id='PE0kI'></bdo><ul id='PE0kI'></ul>
                  1. <small id='PE0kI'></small><noframes id='PE0kI'>

                    <legend id='PE0kI'><style id='PE0kI'><dir id='PE0kI'><q id='PE0kI'></q></dir></style></legend>