【问题标题】:How can I display the only the first two records per column in the database?如何显示数据库中每列的前两条记录?
【发布时间】:2018-06-16 05:10:04
【问题描述】:

这是我正在使用的 PHP。

echo "<td class='leftalign'>";
echo "<tr id='centered' >" . $row['Fund_Yield'] . "</td></tr>";
echo "<tr id='centered' >" . $row['Fund_Benchmark_Yield'] . "</tr>";
echo "<tr id='centered' >" . $row['Class_Yield'] . "</tr>";
echo "<tr id='centered' >" . $row['Special_Class_Yield'] . "</tr>";
echo "<tr id='centered' >" . $row['Plus_minus_Benchmark'] . "</tr>";
echo "<tr id='centered' >" . $row['Plus_Minus_Class'] . "</tr>";
echo "<tr id='centered' >" . $row['Plus_Minus_Special_Class'] . "</tr>";
echo "<tr id='centered' >" . $row['Percentile_Class'] . "</tr>";
echo "<tr id='centered' >" . $row['Percentile_Special_Class'] . "</tr>";

echo"</td>";

每个标签包含 4 条记录,但我只想显示前两条或我指定的任何内容。

【问题讨论】:

  • 您没有发布所有相关代码,但尝试将“LIMIT 2”添加到您的 MySQL SELECT 查询中
  • 您对&lt;td&gt;&lt;tr&gt; 的嵌套也没有任何意义..
  • 删除第二行中&lt;/td&gt; 的第一个实例

标签: php mysql html-table


【解决方案1】:

【讨论】:

  • 但是如果我需要为另一列显示 3 怎么办?
  • 向我们展示您的SELECT 查询。你的问题现在没有意义。你说你需要 2
猜你喜欢
  • 2015-09-05
  • 2018-03-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-02-21
  • 2012-06-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多