miércoles, 23 de octubre de 2013

TABLAS DE MULTIPLICAR BUCLES

HTML

<html>
<head>
<style type="text/css">
[required]
{
border-color:red;
box-shadow: 0px 0px 5px green;
}
</style>
</head> 
<body>
<form action="DO.PHP" method="POST"> 
<table border=2>
<tr><td>VALOR INICIAL</td>
     <td> <input type="integer" name="VI" required> </td>
</tr>
<tr><td>VALOR FINAL</td>
     <td> <input type="integer" name="VF" required></td>
</tr>
<tr><td>NUMERO</td>
     <td> <input type="integer" name="N" required></td>
</tr>
<tr><td> <input type="submit" value="GENERAR"></td> 
</tr>
</table>
</form>
</body>
</html>

PHP FOR

<?php
$VII=$_POST["VI"];
$VFF=$_POST["VF"];
$NN=$_POST["N"];
echo "<table border='1'>";
echo "<tr><td colspan=5><h1>TABLA DEL $NN</h1></td></tr>";
 $CVI=0;
   $CNN=0;
    $Cres=0;
echo"RESULATADO";
echo"<br>";
if($VII<=$VFF){
FOR($i=$VII;$i<=$VFF;$i++)
  { echo "<tr><td>".$i."</td><td>*</td><td>".$NN."</td><td>=</td><td>".$NN*$i."</d></tr>";
    $res=$NN*$i;
     $CVI=$CVI+$i;
   $CNN=$CNN+$NN;
    $Cres=$Cres+$res;
    }
}else{
echo "ERROR";
}
echo "<tr><td colspan=2>$CVI</td><td colspan=2>$CNN</td><td>$Cres</td></tr>";
echo "</table>";
?>



PHP DO

<?php
$VII=$_POST["VI"];
$VFF=$_POST["VF"];
$NN=$_POST["N"];
echo "<table border='1'>";
echo "<tr><td colspan=5><h1>TABLA DEL $NN</h1></td></tr>";
 $CVI=0;
   $CNN=0;
    $Cres=0;
echo"RESULATADO";
echo"<br>";
if($VII<=$VFF){
DO
  {
  $VII++;
  echo "<tr><td>".$VII."</td><td>*</td><td>".$NN."</td><td>=</td><td>".$NN*$VII."</d></tr>";
    $res=$NN*$VII;
         $CVI=$CVI+$VII;
   $CNN=$CNN+$NN;
    $Cres=$Cres+$res;
  }while($VII<$VFF);
}else{
echo "ERROR";
}
echo "<tr><td colspan=2>$CVI</td><td colspan=2>$CNN</td><td>$Cres</td></tr>";
echo "</table>";
?>


PHP WHILE

<?php
$VII=$_POST["VI"];
$VFF=$_POST["VF"];
$NN=$_POST["N"];
echo "<table border='1'>";
echo "<tr><td colspan=5><h1>TABLA DEL $NN</h1></td></tr>";
 $CVI=0;
   $CNN=0;
    $Cres=0;
echo"RESULATADO";
echo"<br>";
if($VII<=$VFF){
while($VII<=$VFF)
  {
  $VII++;
echo "<tr><td>".$VII."</td><td>*</td><td>".$NN."</td><td>=</td><td>".$NN*$VII."</d></tr>";   
   $res=$NN*$VII;
    $CVI=$CVI+$VII;
   $CNN=$CNN+$NN;
    $Cres=$Cres+$res;
  }
}else{
echo "ERROR";
} echo "<tr><td colspan=2>$CVI</td><td colspan=2>$CNN</td><td>$Cres</td></tr>";
echo "</table>";
?>

0 comentarios:

Publicar un comentario