I’m trying to create a multiplication table using PHP but in my code the number 1 is skipped i don’t know why.
Can you please guys help me to solve this problem.
Thanks a lot.
<?php
$codeHTML = '<html>
<head>
<meta charset="utf-8">
<title>Programmation pour le Web</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>';
$codeHTML .= '<body><h1> Table de multiplication </h1>
<table border = "2" width = "100">';
// Creation de la table
for($i = 1; $i < 6; $i++){
$codeHTML .= '<tr>';
for($j = 1; $j < 6; $j++){
$p = $i*$j;
$codeHTML .= "<td> $p </td>";
}
$codeHTML .= '</tr>';
}
$codeHTML .= '</table>
</body>
</html>';
echo $codeHTML;
?>
And i want an output to be like :
x 1 2 3 4 5
1 1 2 3 4 5
2 2 4 6 8 10
3 3 6 9 12 15
4 4 8 12 16 20
5 5 10 15 20 25
2
Answers
When you provide expected outpus is much easier to help you, here is what you want:
Output is:
Is this something you want ?
This will output: