<!DOCTYPE html>
<html lang="it">
<head>
    <meta charset="UTF-8">
    <title>Tavola Pitagorica in PHP</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            color: #333;
        }
        h2 {
            text-align: center;
        }
        table {
            border-collapse: collapse;
            margin: 30px auto;
            background-color: #fff;
            box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        }
        th, td {
            border: 1px solid #ccc;
            width: 45px;
            height: 45px;
            text-align: center;
            vertical-align: middle;
            font-size: 16px;
        }
        th {
            background-color: #eaeaea;
            font-weight: bold;
        }
    </style>
</head>
<body>

    <h2>Tavola Pitagorica</h2>

    <?php
    echo "<table>\n";
    
    // 1. Creiamo la riga di intestazione superiore (con i numeri da 1 a 10)
    echo "<tr>\n";
    echo "<th>×</th>\n"; // Angolo in alto a sinistra
    for ($j = 1; $j <= 10; $j++) {
        echo "<th>$j</th>\n";
    }
    echo "</tr>\n";
    
    // 2. Creiamo le righe della tabella con un ciclo esterno
    for ($i = 1; $i <= 10; $i++) {
        echo "<tr>\n";
        
        // Prima cella di ogni riga: intestazione laterale
        echo "<th>$i</th>\n";
        
        // Ciclo interno per calcolare i prodotti della tabellina
        for ($j = 1; $j <= 10; $j++) {
            $prodotto = $i * $j;
            echo "<td>$prodotto</td>\n";
        }
        
        echo "</tr>\n";
    }
    
    echo "</table>\n";
    ?>

</body>
</html>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: