8. VTU WEB TECHNOLOGY LAB | READ NOW

 VTU WEB TECHNOLOGY LAB

8] WRITE THE PHP PROGRAMS TO DO THE FOLLOWING:

  1. IMPLEMENT SIMPLE CALCULATOR OPERATIONS.
  2. FIND THE TRANSPOSE OF A MATRIX.
  3. MULTIPLICATION OF TWO MATRICES.
  4. ADDITION OF TWO MATRICES.

STEPS TO EXECUTE PHP PROGRAM

  1. Copy the php code given below
  2. Save it with .php file name extension
  3. Place the file in the htdocs of XAAMP
  4. Start the XAAMP control panel
  5. Start Apache server
  6. Click on admin in XAMPP Control pale
  7. Replace the url dashboard name with your php file name
  8. Execution completed

Solution – pgor8a.php

<html>
 <head>
 <style>
  table, td, th {
   border: 1px solid black; 
   width: 35%;
   text-align: center; 
   background-color: lightgray;
  }
  table { margin: auto; } 
  input,p { text-align:right; }
 </style>
</head>

<body>
 <form method="post" action="prog8a.php">
  <table>
  <caption><h2> SIMPLE CALCULATOR </h2></caption>
  <tr>
   <td>First Number:</td><td><input type="text" name="num1" /></td>
   <td rowspan="2"><button type="submit" name="submit" value="calculate">Calculate</td></tr>
  <tr>
   <td>Second Number:</td><td><input type="text" name="num2"/></td>
  </tr>
 </form>
 
 <?php
 if(isset($_POST['submit'])) // it checks if the input submit is filled
 {
  $num1 = $_POST['num1'];
  $num2 = $_POST['num2']; 
  if(is_numeric($num1) and is_numeric($num2) )
  {
   echo "<tr><td> Addition :</td><td><p>".($num1+$num2)."</p></td>"; 
   echo "<tr><td> Subtraction :</td><td><p> ".($num1-$num2)."</p></td>"; 
   echo "<tr><td> Multiplication :</td><td><p>".($num1*$num2)."</p></td>"; 
   echo "<tr><td>Division :</td><td><p> ".($num1/$num2)."</p></td>";
   echo "</table>";
  }
  else
  {
   echo"<script> alert(' ENTER VALID NUMBER');</script>";
  }
 }
 ?>
</body>
</html>

WEB TECHNOLOGY – Output

WEB TECHNOLOGY

Leave a Reply

Your email address will not be published. Required fields are marked *

WhatsApp Icon Join For Job Alerts