duanlu9970 2009-10-31 00:55
浏览 46
已采纳

PHP fmod问题

<?php
$i = 1;
$y = 5;
?>
<?php while (have_posts()) : the_post(); ?>
<?php
if (fmod($i, $y) == 0) {
    echo '<tr>';
}
?>

What i'm doing wrong? I want every 5 time to show the <tr>,any help?

  • 写回答

2条回答 默认 最新

  • duanchu9914 2009-10-31 01:05
    关注

    I don't see where you increment $i; nor why you are using fmod instead of % (fmod is only for floating-point moduli). Try this code:

    <?php
    $i = 1;
    $y = 5;
    while (have_posts())
    {
      the_post();
      if ($i % $y == 0) echo '<tr>';
      $i++;
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?