Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revision Both sides next revision
dvprog_06_2 [2017-09-22 10:27]
Daniel Viström created
dvprog_06_2 [2017-09-22 10:34]
Daniel Viström
Line 1: Line 1:
 ====== Genomgång - Nästlade loopar ====== ====== Genomgång - Nästlade loopar ======
  
 +Gör en tabell som skriver ut tal 1 - 100 i en tabell med tio tal på varje rad.
  
-<code php>+{{:tabell100.jpg?400|}}
  
 +<code php>
 +<?php
 +include('head.php');
 + 
 +$i = 0;  //Tiotal
 +echo '<table>';
 +while ($i < 10){    // Loopa $i från 0 - 9
 +  echo '<tr>';      // Ny rad
 +  $j = 1;           // Ental
 +  while ($j < 11){  // För varje värde på $i loopas $j från 1 - 10
 +    $ut = $i * 10 + $j; 
 +    echo '<td>' . $ut . '</td>';  // En cell för varje varv i loopen
 +    $j++;
 +  }
 +  echo '</tr>';     // Slut på rad
 +  $i++;
 +}
 +echo '</table>';
 + 
 +include('foot.php');
 +?>
 </code> </code>