I am trying to make a php script that allows me to create the existing multiplication tables between two chosen numbers. For example between 10 and 20. Any ideas?
Thanks
I am trying to make a php script that allows me to create the existing multiplication tables between two chosen numbers. For example between 10 and 20. Any ideas?
Thanks
So fast done in $uno
equal to the first value and in $dos
the second and $multiplicarHasta
I put 11 because in the for
if I put 10 that is the maximum in the multiplication table is made up to 9 is only for that.
Then there are two for, in the first you get the numbers between $uno
and $dos
, and in the second one each of your values you multiply them up to ten:
<style>
#datos {
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
border-collapse: collapse;
width: 30%;
text-align: center;
}
#datos td, #datos th {
border: 1px solid #ddd;
padding: 8px;
}
#datos tr:nth-child(even){background-color: #f2f2f2;}
#datos tr:hover {background-color: #ddd;}
#datos th {
padding-top: 12px;
padding-bottom: 12px;
text-align: left;
background-color: #4CAF50;
color: white;
}
</style>
<?php
$uno = 1;
$dos = 2;
$multiplicarHasta = 11;
for ($i=$uno; $i < ($dos + 1); $i++) {
echo "<table id='datos'><tr>";
echo "<th>Tabla del ".$i."</th></tr>";
for ($j=1; $j < $multiplicarHasta; $j++) {
echo "<tr><td>".$i. " x ".$j." = ".$i * $j."</td></tr>";
}
echo "</table>";
echo "<br>";
}
I give an example of how he returns them because I do not know how to put code to run here. The only thing that you have to change to see other values would be the value of $ one and the value of $ two (from - to)