从mysql数据库输出中排除一行


excluding a row from a mysql database outputting

从数据库中提取的第三个元素将在大框中输出,而其他元素将在小框中输出。我需要它做的是在输出小框时排除第三个元素。关于如何做到这一点有什么想法吗?

while($array = mysql_fetch_assoc($result)) {
if($i % 3 == 0) {
// large box
echo '<div class="box" style="width: 692px; height: 218px">' . $array['feedName'] . '</div>';
}
// small box
echo '<div class="box" style="width: 246px; height: 218px">' . $array['feedName'] . "<br></div>";
// exclude the third element
$i++;
}
}

如果我正确理解你想要什么(每第三项都在大盒子里,而不是小盒子里),你只需要在你的if中使用else条款。

while($array = mysql_fetch_assoc($result)) {
    if($i % 3 == 0) {
        // large box
        echo '<div class="box" style="width: 692px; height: 218px">' . $array['feedName'] . '</div>';
    }
    else {
        // small box
        echo '<div class="box" style="width: 246px; height: 218px">' . $array['feedName'] . "<br></div>";
    }
    $i++;
}
divide by 6 and get the remainder (%)
if (remainder == 0 or 3) {
    large box
} else if (remainder == 1 or 5) {
    small box
}