Multiplication Table of a number using PHP

Multiplication Table

A multiplication table, also known as a times table or multiplication chart, is a mathematical reference used to display the multiplication products of numbers in a systematic and organized way. It is a helpful tool for learning and practicing multiplication facts, especially for students who are just beginning to understand multiplication.

Multiplication Table using PHP

<link rel="stylesheet" href=""/>
    padding: 40px;
    background: #ffb077;
<div class="container mt-5">
  <div class="row justify-content-center">
    <div class="col-6">
      <div class="box">
        <form action="" method="get">
          <div class="row">
            <div class="col-5">
            <div class="col-7">
              <input type="text" name="number" class="form-control">
    <div class="col-6">
      <?php if(isset($_GET['number'])){?>
        <?php $number = $_GET['number'];?>
        <div class="box">
          <h3>Multiplication Table of <?php echo $number;?></h3>
          <table class="mt-3 table table-bordered table-striped">
              <?php for($i=1;$i<=10;$i++){?>
                  <td class="text-center">
                    <?php echo $number;?> * <?php echo $i;?> = <?php echo $number*$i;?>
              <?php } ?>
      <?php } ?>

Follow this video for complete guidance :

This code creates a simple HTML form where users can enter a number. Upon submitting the form, the PHP code generates a multiplication table for that number and displays it in a basic HTML table structure.

ALSO READ  Make your own ChatGPT using OpenAI API with PHP

Comments are closed.