我正在做的是,对于每第 3 个输出的 MySQL 数据库行,我将运行一个输出不同的自定义函数。我如何识别每第 3 行?
最佳答案
很简单。你可以这样做:
$i = 1;
while ( $array = mysql_fetch_assoc($result) )
{
if ($i % 3 == 0)
{
// call other function
}
$i++;
}
请注意 modulus operator 的使用.
关于php - 识别 MySQL while 循环中的第 3 行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8250341/