Created
January 31, 2025 09:20
-
-
Save Steellgold/07226bdfa275d748945e6d2761b03df7 to your computer and use it in GitHub Desktop.
Jonathan
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function genTables($n, $m = 10) { | |
$result = []; | |
for ($i = 1; $i <= $m; $i++) { | |
$result[$i] = "$n x $i = " . ($n * $i); | |
} | |
return $result; | |
} | |
?> | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
</head> | |
<body> | |
<div> | |
<h1>Multiplication Tables</h1> | |
<form method="POST"> | |
<label for="number">Enter a number:</label> | |
<input type="number" id="number" name="number" required> | |
<label for="multiples">Enter a multiple:</label> | |
<input type="number" id="multiples" name="multiples" required> | |
<button type="submit">Generate</button> | |
</form> | |
<?php | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
$number = $_POST['number']; | |
$multiples = $_POST['multiples']; | |
$tables = genTables($number, $multiples ?? 10); | |
echo "<h2>Multiplication Table for $number (x $multiples)</h2>"; | |
echo "<ul>"; | |
foreach ($tables as $table) { | |
echo "<li>$table</li>"; | |
} | |
echo "</ul>"; | |
} | |
?> | |
</div> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
background-color: #f4f4f4; | |
margin: 0; | |
padding: 20px; | |
} | |
h1, h2 { | |
color: #333; | |
} | |
form { | |
margin-bottom: 20px; | |
} | |
input[type="number"] { | |
padding: 10px; | |
width: 50px; | |
} | |
button { | |
padding: 10px 15px; | |
background-color: #28a745; | |
color: white; | |
border: none; | |
cursor: pointer; | |
} | |
button:hover { | |
background-color: #218838; | |
} | |
ul { | |
list-style-type: none; | |
padding: 0; | |
} | |
li { | |
background: #fff; | |
margin: 5px 0; | |
padding: 10px; | |
border-radius: 5px; | |
} | |
</style> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment