Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // TODO: Implement meh
- if(isset($_POST))
- {
- $rows=$_POST['rows'];
- $columns=$_POST['columns'];
- $operations=$_POST['operation'];
- $counterColumns = 0;
- $counterRows = 0;
- if(is_numeric($rows) == false || $rows<0)
- {
- echo "Invalid row input.";
- }
- else
- {
- if($operations == 'multiplication')
- {
- echo "This is the ".$columns." x ".$rows." multiplication table.";
- }
- else
- {
- echo "This is the ".$columns." + ".$rows." addition table.";
- }
- echo "<table border=\"1\">";
- //for loop for table rows
- for($counterRows; $counterRows <= $rows; $counterRows++)
- {
- echo "<tr>";
- for($counterColumns = 0; $counterColumns <= $columns; $counterColumns++)
- {
- echo "<td>";
- if($operations == 'multiplication')
- {
- if($counterRows == 0)
- {
- echo $counterColumns;
- }
- else if($counterColumns == 0)
- {
- echo $counterRows;
- }
- else
- {
- $calc= $counterRows * $counterColumns;
- }
- }
- else
- {
- $calc=$counterRows + $counterColumns;
- }
- echo(htmlspecialchars($calc));
- echo "</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement