Question

Write a PHP program using a ''FOR loop' to compute and print the employee's salary for...

Write a PHP program using a ''FOR loop' to compute and print the employee's salary for some number of years with a percent increase each year. Your submit button should re-call this page and use PHP to create a table of salaries for each year starting at 1 up to the value of the years variable. So if 'years' is equal to 5, there should be 5 rows in your table. For each year, the salary increases by X%. Make sure your money values are rounded to 2 decimal places.

<div id="contentwrap">

   <div id="maintitle">

       Salary List using PHP

   </div>

   <form method="get" action="employeepay.php">
  
       <!-- Starting salary textbox -->
       <div style="margin-top:20px;" class="formtext">Enter starting salary</div>
       <input type="text" class="formfield" name="salary" />
      
       <!-- Interest rate textboox -->
       <div style="margin-top:20px;" class="formtext">Enter interest rate</div>
       <input type="text" class="formfield" name="intrate" />
      
       <!-- Enter years to list -->
       <div style="margin-top:20px;" class="formtext">Enter years to list</div>
       <input type="text" class="formfield" name="years" />
      
       <!-- List salary button -->
       <div style="margin-top:25px;">
           <input type="submit" value="List Salary"/>
       </div>
          
   </form>
  
   <div id="infowrap">
<table border="3" width="75%">
  
<tr id="headrow">
<td>Year</td>
<td>Salary</td>
</tr>
  
<!-- the code to process your form goes here -->
<?php
---for loop goes here----using tables------
  
  
?>

  
  
</table>


  
  
  
  
  
  
   </div><!-- ends infowrap (table) -->

</div> <!-- ends div#contentwrap -->

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student ,

As per requirement submitted above kindly find below solution.

Here new web page with name "employeepay.php" is created which contains below code.

employeepay.php :

<!DOCTYPE html>

<html lang="en">

    <head>

        <title></title>

        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1">

        <link href="css/style.css" rel="stylesheet">

    </head>

    <body>

    <div id="contentwrap">

   <div id="maintitle">

       Salary List using PHP

   </div>

   <form method="post" action="employeepay.php">

       <!-- Starting salary textbox -->

       <div style="margin-top:20px;" class="formtext">Enter starting salary</div>

       <input type="text" class="formfield" name="salary" />

       <!-- Interest rate textboox -->

       <div style="margin-top:20px;" class="formtext">Enter interest rate</div>

       <input type="text" class="formfield" name="intrate" />

      

       <!-- Enter years to list -->

       <div style="margin-top:20px;" class="formtext">Enter years to list</div>

       <input type="text" class="formfield" name="years" />

      

       <!-- List salary button -->

       <div style="margin-top:25px;">

           <input type="submit" value="List Salary" name="btnList"/>

       </div>

          

   </form>

  

   <div id="infowrap">

       <?php

        if(isset($_POST['btnList']))

        {

            //taking salary

            $salary=$_POST['salary'];

            //taking interest rate

            $rate=$_POST['intrate'];

            //taking years

            $years=$_POST['years'];

        

       ?>

<table border="3" width="75%">

  

<tr id="headrow">

<td>Year</td>

<td>Salary</td>

</tr>

<!-- below line will create first row in the table -->

<tr><td>1</td><td><?php echo number_format($salary,2)?></td></tr>

<!-- the code to process your form goes here -->

<?php

//using for each loop

for($i=2;$i<=$years;$i++)

{

     //calculate increased salary

     $newSalary=$salary+$salary*$rate/100;

     $salary=$newSalary;

     ?>

     <!-- below line of code will create number of rows -->

    <tr><td><?php echo $i ?></td><td><?php echo number_format($newSalary,2)?></td></tr>

    <?php

}

  

}

?>

</table>

   </div><!-- ends infowrap (table) -->

</div> <!-- ends div#contentwrap -->

</body>

</html>

==================================

Output :Open web page employeepay.php in the browser and will get the screen as shown below.

Screen 1:employeepay.php

Screen 2:employeepay.php

NOTE :PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
Write a PHP program using a ''FOR loop' to compute and print the employee's salary for...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PHP code that is given : <?php // Here is where your preprocessing code goes //...

    PHP code that is given : <?php // Here is where your preprocessing code goes // An example is already given to you for the First Name $fname = $_GET['fname']; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Exercise 2 - GET Echo</title> <style> body { margin:0; padding:0; font-family: Arial; } form { margin:20px; } input[type="text"], input[type="password"] { width:150px; padding:3px; font-size:1em; } input[type="submit"] { padding:3px; font-size:1em; } label { display:inline-block; width:150px; } .input-container { padding:5px; } </style> </head> <body> <form...

  • How to make all the buttons work using javascript? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta...

    How to make all the buttons work using javascript? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> function openAccount() { /* - get the account and initial amount values - check that all necessary information is provided - call the setCookie function to create account */ } function Deposit() { /* - get the account and amount values - check that all necessary information is provided - alter cookie with current amount of deposit */ } function...

  • HTML Coding <html> <head> <title> Contact -- Charles Robertson </title> </head> <body bgcolor="white"> <table width="700" height="500"...

    HTML Coding <html> <head> <title> Contact -- Charles Robertson </title> </head> <body bgcolor="white"> <table width="700" height="500" border="10"> <!-----row---1----logo---> <tr><td> <img src="20150516_084745" width="700" height="200"> </td></tr> <!-----row-2-navigation-----> <tr><td> <!----start-navigation-table----> <table width="700" height="100" border="5" bgcolor="lightgreen" > <tr><td><a href="HerbFarm.html"> <center> HOME </center></a></td> <td><a href="about3.html"> <center> ABOUT </center></a></td> <td><a href="contact3.html"> <center> CONTACT </center></a></td> <td><a href="gallery3.html"> <center> GALLERY </center></a></td> </tr> </table> <!------end-navigation-table----> </td></tr> <tr><td> <h1>Contact </h1> <form action="thankyou.html">    </form> <div class="row"> <div class="col-75"> <div class="container"> <form action="/action_page.php"> <div class="row"> <div class="col-50"> <h3>Billing Address</h3> <label for="fname"><i...

  • PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head>...

    PHP Can't get my code to work, what am I doing wrong? <!DOCTYPE html> <html> <head> <script> </script> </head> <body> <h2>Temperature Conversion Table</h2> <h4>Enter a starting value in degrees Fahrenheit and an increment value.</h4> <form name="myTemp" onsubmit="convertCelcius()" method="post"> <input type="text" name="temperature"> Enter an value in degrees Fahrenheit<br><br> <input type="radio" name="degIncrement" id="degIncrement5"> Convert in increment in 5 degrees<br> <input type="radio" name="degIncrement" id="degIncrement10"> Convert in increment in 10 degrees <br/><br/><input type="submit" value="Submit"> </form> <?php if( $_POST["temperature"] || $_POST["degincrement"] ) { //get he...

  • i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search"...

    i'm having trouble with 1 and 3 using html, javascript and jquery 1) Change the "Search" link on the left to a button that when clicked, hide all the fields on the form and display the text "This is a search feature..." 3) When the user fills the form and clicks "Login", the values inputted should be displayed in the empty row (under Login) of the page. The display should be in the form: Student ID: <input value> Student Name:...

  • Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php...

    Q1. rewrite the exercise on April 4 by adding the following operations: 1) In the php script, create an associative array named $order that stores the following values: - the number of cheese toppings; - the number of pepperoni toppings; - the number of ham toppings; - the size of the ordered pizza; - the number of the ordered pizza; - the total cost of the order; - the discount rate; - the total cost after the discount. 2) the...

  • I need HELP to get the code to do these function: If I keep clicking "Generate"...

    I need HELP to get the code to do these function: If I keep clicking "Generate" multiple times, the list keeps on getting bigger. The number of rows should always be equal to the number of columns. Also make the code to show both table at the same time? Here is the code I got some far : Code: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>Testing</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous"> </head> <style> td...

  • <!DOCTYPE html> <html> <head> <title>Products</title> <style> .heading { text-align: center; font-size: 40px; } #menu { text-align:...

    <!DOCTYPE html> <html> <head> <title>Products</title> <style> .heading { text-align: center; font-size: 40px; } #menu { text-align: center; } #menu li { display: inline; font-size: 26px; margin-left: 20px; } .container{ overflow: hidden; margin: 30px; } img { float: left; width: 40vh; height: 40vh; margin-left: 10%; } table { float: right; margin-right: 10%; } table, th, td { border: 1px solid black; border-collapse: collapse; } th, td { font-size: 26px; padding: 10px; text-align: left; } a { color: black; } a:visted {...

  • LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but,...

    LANGUAGE JAVASCRIPT, PHP Need help with PHP and ajax code. The user needs to login but, I keep getting an error that I coded "Wrong username and password!" ***PLEASE DONT GIVE ME A NEW CODE THAT IS NOWHERE NEAR THE CODE I SUBMITTED***** PLEASE LOOK AT THE CODE AND SEE ANY ISSUES login.html <!DOCTYPE html> <html> <head> <title>login popup</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script> <style type="text/css"> body { background-color: white; } </style> </head> <body> <center> <h1 style="text-align: center;"> Login </h1> <form>             Login ID:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT