Advertisement
gitlez

YA: Payroll Entry wPHP

Apr 22nd, 2012
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.16 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Payroll Form</title>
  4.         <style type="text/css">
  5.             /*    Simple styles to make it look a little nicer    */
  6.             input {
  7.                 margin-right: 15px;
  8.             }
  9.             input[name*=rate], input[name*=hours] {
  10.                 width: 50px;
  11.             }
  12.         </style>
  13.     </head>
  14. <body>
  15.     <form method="post" action="payroll_process.php">
  16.         Company Name: <input type="text" name="company_name">
  17.         <br>
  18.         Date: <input type="text" name="date">
  19.         <br>
  20. <?php
  21. /*    Same Result, less typing    */
  22. $numOfEmployees = 5;
  23.  
  24. for( $i=0; $i<$numOfEmployees; ++$i){
  25.     echo '
  26.        <fieldset>
  27.            <h3>Employee #' . ($i + 1) . '</h3>
  28.            Name: <input type="text" name="employee[' . $i . '][name]">
  29.            Rate/Hour: $<input type="text" name="employee[' . $i . '][rate]">
  30.            Hours Worked: <input type="text" name="employee[' . $i . '][hours]">
  31.        </fieldset>';
  32.  
  33. }
  34. // ($i + 1) instead of $i++, because we do not want to change $i, merely use the value of
  35. ?>
  36.         <input type="submit" value="Submit">
  37.     </form>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement