Facebook
From Beefy Goat, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 213
  1. <!DOCTYPE html>
  2. <html lang="PL">
  3.   <head>
  4.     <title>Tabliczka mnożenia</title>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.   </head>
  7. <body>
  8. <form method="POST" action="tabliczka-mnozenia.php">
  9.                 <label>Podaj pierwszą liczbe: </label>
  10.                 <input type="number" name="liczba" min="1"><br>
  11.                 <input type="submit" name="wyslij" value="Wypisz">
  12.         </form>
  13.    
  14. <?php
  15. echo "<table><tr><th></th>";
  16. if(isset($_POST["wyslij"]))            
  17. {
  18. $liczba_wierszy = $_POST["liczba"];
  19. $liczba_kolumn = $_POST["liczba"];
  20.  
  21. for ($i = 1; $i <= $liczba_kolumn; $i++) {
  22.   echo '<th>' . $i . '</th>';
  23. }
  24. }
  25. echo '</tr>';
  26.  
  27. for ($i = 1; $i <= $liczba_wierszy; $i++) {
  28.     echo '<tr>';
  29.     echo '<th>' . $i . '</th>';    
  30.     for ($j = 1; $j <= $liczba_kolumn; $j++) {    
  31.         echo '<td>';
  32.         echo $j * $i;
  33.         echo '</td>';
  34.     }
  35.     echo '</tr>';    
  36. }
  37.  
  38. echo "</table>";
  39. ?>
  40.  
  41.  
  42. </body>
  43. </html>