problem with while to throw results

0

Good I'm doing a multiplication table but at the time of passing it to a while does not throw me the last two tables throws me the first but the others do not have this already working with a for the syntax is the same I do not know that the problem is due

this is with for this if it works:

   <!DOCTYPE html>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="tablass.css"
<html lang="es">
<head>

<title> </title>

</head>
<body>
<?php
$b=2;
$d=3;
$w=4;
$multi;
echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $b </th></tr>";

 for($i=6; $i<=8; $i++) { 

    $multi= $i * $b;
echo "<tr><td align=center>$b</td>
             <td align=center>x</td>
             <td align=center>$i</td>
             <td align=center>=</td>
             <td align=center> ". $b*$i . "</td>
         </tr>";
 }
 echo "</table> <br/>";


echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $d </th></tr>";
 for($i=6; $i<=8; $i++) { 

    $multi= $i * $d;
echo "<tr><td align=center>$d</td>
             <td align=center>x</td>
             <td align=center>$i</td>
             <td align=center>=</td>
             <td align=center> ". $d*$i . "</td>
         </tr>";
 }
 echo "</table> <br/>";

echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $w </th></tr>";
 for($i=6; $i<=8; $i++) { 

    $multi= $i * $w;
echo "<tr><td align=center>$w</td>
             <td align=center>x</td>
             <td align=center>$i</td>
             <td align=center>=</td>
             <td align=center> ". $w*$i . "</td>
         </tr>";
 }
 echo "</table> <br/>";
?>

here with while worse does not throw the last two tables:

    <!DOCTYPE html>
<meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="tablass.css"
<html lang="es">
<head>

<title> </title>

</head>
<body>



<?php

$i=6;
$b=2;
$w=3;
$d=4;
echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $b </th></tr>";


while($i<=8){
    $multi=$i * $b;
    echo "<tr><td align=center>$b</td>
             <td align=center>x</td>
             <td align=center>$i</td>
             <td align=center>=</td>
             <td align=center> ". $b*$i . "</td>
         </tr>";


    $i++;


}

echo "</table> <br/>";


echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $w </th></tr>";

while($i<=8){
    $multi=$i * $w;

    echo "<tr><td align=center>$w</td>
          <td align=center>x</td>
          <td align=center>$i</td>
          <td align=center>=</td>
          <td align=center> ". $w*$i . "</td>
          </tr>";


          $i++;

}
echo "</table> <br/>";



echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $d </th></tr>";


while($i<=8){
    $multi=$i * $d;

    echo "<tr><td align=center>$d</td>
          <td align=center>x</td>
          <td align=center>$i</td>
          <td align=center>=</td>
          <td align=center> ". $d*$i . "</td>
          </tr>";


          $i++;

}
echo "</table> <br/>"

?>

I do not know what happens when the other jobs are not repainted, print one more

    
asked by wdwd 12.04.2018 в 21:42
source

1 answer

1

You have to reset the value of $ i after the first while, since it ended with the value 9 :

<?php

$i=6;
$b=2;
$w=3;
$d=4;
echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $b </th></tr>";


while($i<=8){
    $multi=$i * $b;
    echo "<tr><td align=center>$b</td>
             <td align=center>x</td>
             <td align=center>$i</td>
             <td align=center>=</td>
             <td align=center> ". $b*$i . "</td>
         </tr>";


    $i++;


}

echo "</table> <br/>";

$i = 6; //Para poder continuar con el while

echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $w </th></tr>";

while($i<=8){
    $multi=$i * $w;

    echo "<tr><td align=center>$w</td>
          <td align=center>x</td>
          <td align=center>$i</td>
          <td align=center>=</td>
          <td align=center> ". $w*$i . "</td>
          </tr>";


          $i++;

}
echo "</table> <br/>";

$i = 6; //Para poder continuar con el while

echo"<table border=1 cellspacing=0 width=200";
echo "<tr><th colspan=5> Tabla del $d </th></tr>";


while($i<=8){
    $multi=$i * $d;

    echo "<tr><td align=center>$d</td>
          <td align=center>x</td>
          <td align=center>$i</td>
          <td align=center>=</td>
          <td align=center> ". $d*$i . "</td>
          </tr>";


          $i++;

}
echo "</table> <br/>"
    
answered by 13.04.2018 / 05:21
source