【问题标题】:Spliting Results of PHP Query into Columns将 PHP 查询的结果拆分为列
【发布时间】:2011-12-24 12:32:35
【问题描述】:

我在使用 PHP 和 HTML 让这个查询显示为四列时遇到了一点问题。我希望 $manufacturers_query 在 4 列中显示结果。因此,无论有多少行,我都希望结果显示在 4 列中。请在下面找到代码sn-p:

$row = 0;
$manufacturers_query = tep_db_query("select manufacturers_name, manufacturers_id from "     .     TABLE_MANUFACTURERS . " order by manufacturers_name" );
while ($manufacturers = tep_db_fetch_array($manufacturers_query)) {
$row++;
echo '<a href="' . tep_href_link(FILENAME_DEFAULT, 'manufacturers_id=' .                 $manufacturers['manufacturers_id'] . '=' . $manufacturers['manufacturers_name'], 'NONSSL')     .     '">'. $manufacturers['manufacturers_name'] . ' <br> ';
}
echo "</a><br><br>\n";
if ((($row / 4) == floor($row / 4))) {

我需要将此列在 4 列中,但不知道我哪里出错了。我知道我的设计是错误的,但更多的眼睛比两个更好?

有什么帮助吗?提前非常感谢!

【问题讨论】:

标签: php mysql css


【解决方案1】:

这会每 4 行返回 true

if ( $row % 4 == 0 ) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多