Döngüsü için bir sayım!

0 Cevap

Ben bu işe almak ve sadece cant sayısı hakkını almak için her şeyi denedim.

                        <?php
                    $total = count($u);
                    for ($i = 0; $i < $total; $i++) 
                    {
                        $j = 0;
                        $s = $database->checkUserPlayedRecent($u[$i]);
                        if (mysql_num_rows($s) > 0)
                        {
                            $j = $j + 1;
                            ?>
                            <tr>
                                    <?php
                                        echo "<td>$j</td>";
                                    ?>

                                    <?php
                                        echo "<td>$u[$i]</td>";
                                    ?>
                                    <?php
                                        echo "<td>$p[$i]</td>";
                                    ?>
                            </tr>
                            <?
                        }
                    }
                    ?>

I am trying to increment $j each time but ONLY for the results from num_rows. Originally $j was $i + 1 but that wont work as I am not showing every result from the for loop, only those with num_rows returned. Any help here? Cheers

0 Cevap