MySQL - 如何在多列html table, 单列mysql table中显示

MySQL - How to show in multiple columns html table, single column of mysql table

我想知道如何在我的 php 文件中显示 html 具有多个列的 table 但在该列中仅显示来自 mysqli[=17 的单个列结果=]

我目前拥有的是:

<?php

include "dbinc.php";

$con=mysqli_connect($servername,$username,$password,$database);

$letramasculinos = mysqli_query($con,"SELECT nome FROM nomes WHERE nome LIKE '$_POST[letra]%' AND sexo = 'm';");
$letrafemininos = mysqli_query($con,"SELECT nome FROM nomes WHERE nome LIKE '$_POST[letra]%' AND sexo = 'f';");

     (more code...)

echo "<table style='display: inline-block;' width='150px' border='1' bgcolor='#6699FF'>";
while($row = mysqli_fetch_array($letramasculinos))
{
echo "<tr>";
echo "<td><center>" . $row['nome'] . "</center></td>";
echo "</tr>";
echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

echo "<table style='display: inline-block;' width='150px' border='1' bgcolor='#FF99FF'>";

while($row = mysqli_fetch_array($letrafemininos))
{
echo "<tr>";
echo "<td><center>" . $row['nome'] . "</center></td>";
echo "</tr>";
}
echo "</table>";
}

     (more code...)

?>

在这个示例代码中,它显示了 2 HTML tables 和 1 列,但由于条目太多,我想将该列除以 3 列(或除以 4 或 5,等等。 .) 在每个 table.

我该怎么做?

示例:

我拥有的和我想要的

  I have this:      I Want Something like this:

  +---------+     +--------+---------+--------+
  | Diogo   |     | Diogo  | André   | João   |
  +---------+     +--------+---------+--------+
  | André   |     | Filipe | Carlos  | Gaspar |
  +---------+     +--------+---------+--------+
  | João    |     | Fabio  | Fernado |        |
  +---------+     +--------+---------+--------+
  | Filipe  |
  +---------+
  | Carlos  |
  +---------+
  | Gaspar  |
  +---------+
  | Fabio   |
  +---------+
  | Fernado |
  +---------+

我不是 php 人,但一些算法可能会有所帮助。1) 获取男性/女性的记录数

"SELECT count(*)FROM nomes WHERE nome LIKE '$_POST[letra]%' AND sexo = 'f'; ..... same for 'male'.  

将其保存到 mcount 和 fcount 变量。

if mcount >10
then 
 noOfColms=mcount /10;
 i=0;
 put "<table>"
loop records 
i=i+1;
put "<tr>"
if(i<noOfColms)
   put "<td>" + data +"</td>"
if i==noOfColms
put "</tr>"     
end loop   
put "</table>"

其他 显示列表视图

对 fcount 做同样的事情