continue and break in while loop

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
acousticsman
New php-forum User
New php-forum User
Posts: 10
Joined: Tue Nov 03, 2015 3:51 pm

Thu Jun 15, 2017 10:38 pm

I have four rows of data that will output in a while loop, and I want to include something after two rows,

I understand that it would be a break/continue scenario, but I am not getting the execution

So the code is pretty straight forward:

Code: Select all

<?php  

          $ronaldo1617 = "SELECT * FROM ronaldo1617totals";

          $ronaldo1617result = mysqli_query($db,$ronaldo1617);
          $ronaldo1617final = '';
          $i = 1;
          while($pager1617 = mysqli_fetch_assoc($ronaldo1617result)){

            $id = $pager1617['id'];
            $title = $pager1617['title'];
            $club = $pager1617['club'];
            $international = $pager1617['international'];
            $icon = $pager1617['icon'];

            $totalstat = $club+$international;

            $ronaldo1617final .=  "<div class='ronaldowholestat'>
                                  <h1 class='subheading'>" . $title . "</h1>
                                  <div class='ronaldoiconwrapper'>
                                  <div class='iconwraper'><img class='icon' src='images/" . $icon . "' width='50'>
                                  </div>
                                  <div class='mainstat'>
                                  <div class='mainstattext'>" . $totalstat . "</div>
                                  </div>
                                  </div>
                                  <div class='mainstatsub'>CLUB <span class='mainstatsubcontrast'>" . $club . "</span>
                                  </div>
                                  <div class='mainstatsub'>INTERNATIONAL&nbsp;<span class='mainstatsubcontrast'>" . $international . "</span>
                                  </div>
                                  </div>
                                  ";


          }


          ?>
so once it has rendered two rows of data I want to include a php file what will make a pie chart. and then to continue rendering the other two rows.

How would I do this?

chorn
php-forum Active User
php-forum Active User
Posts: 381
Joined: Fri Apr 01, 2016 2:18 am

Fri Jun 16, 2017 1:15 am

just do it, try modulo operation, no need to break or continue until you do not want to skip lines.

User avatar
hyper
php-forum Active User
php-forum Active User
Posts: 451
Joined: Mon Feb 22, 2016 5:52 pm

Fri Jun 16, 2017 3:42 am

Use a function not an include file otherwise you will probably have problems.

As chorn said you can use the modulo operator which is a percent sign %

Post Reply