How do i get the variable values to show up in the table usi
How do i get the variable values to show up in the table using echo? It is currently only showing me the variable name when being displayed.
<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">
 <?php # Script 1.8 - paycheck.php
// Set the variables:
 $firstname = $_REQUEST[\'firstName\'];
 $lastname = $_REQUEST[\'lastName\'];
 $hours = $_REQUEST[\'hours\'];
 $hourlyrate = $_REQUEST[\'hourlyrate\'];
 $ficarate = 5.65;
 $federalrate = 5.75;
 $staterate = 28;
$employeename = $firstname . \",\". $lastname;
 $regularpay = $hours * $hourlyrate;
 $overtime = $hours - 40;
 $overtimepay = ($overtime * 1.5) * $hourlyrate;
 $grosspay = $regularpay + $overtimepay;
 $statetax = ($staterate / 100) * $grosspay;
 $federaltax = ($federalrate / 100) * $grosspay;
 $ficatax = ($ficarate / 100) * $grosspay;//
 $totaltax = ($ficarate + $staterate + $federalrate) ;
 $netpay = ($grosspay - $totaltax);
#firstname check
if(empty($_REQUEST[\'firstname\']))
{ $firstname=NULL;
echo \'<p class=\"error\">You Must enter a first name</p>\';
}
else{$firstname=$_REQUEST[\'firstname\'];
}
#lastname check
if(empty($_REQUEST[\'lastname\']))
{ $lastname=NULL;
echo \'<p class=\"error\">Please enter a last name</p>\';
}
else{$lastname=$_POST[\'lastname\'];
}
# hourly rate check
 if(empty($_REQUEST[\'hourlyrate\']))
{ $hoursworked=NULL;
echo \'<p class=\"error\">You must enter an Hourly Rate that is between 7.25 and 100.00</p>\';
}
elseif ($_REQUEST[\'hourlyrate\']<0 || $_REQUEST[\'hourlyrate\']>100)
{
echo \'<p class=\"error\"> You must enter an Hourly Rate that is between 7.25 and 100.00.</p>\';
$hourlyrate=NULL;
}
else{$hourlyrate=$_POST[\'hourlyrate\'];
}
if (empty($_REQUEST[\'hourlyrate\'])) {
 $rhw = NULL;
 echo \'<p class=\"error\">You forgot to enter your hourly rate!</p>\';
 }
 elseif ($_REQUEST[\'hourlyrate\'] < 0 || $_REQUEST[\'hourlyrate\'] > 100)
 {
 
 echo \'<p class=\"error\">You need to enter an hourly rate between 0 and 100</p>\';
 $rhw = NULL;
 }
 else { $hourlyrate = $_POST[\'hourlyrate\'];
 $hours = number_format ($hours,2);
 $regularpay = number_format($regularpay,2);
 $overtimepay = number_format ($overtimepay, 2);
 $overtime = number_format ($overtime, 2);
 $hourlyrate = number_format ($hourlyrate,2);
 $ficarate = number_format($ficarate, 2);
 $ficatax = number_format ($ficatax,2);
 $staterate = number_format($staterate,2);
 $statetax = number_format($statetax,2);
 $federalrate = number_format($federalrate, 2);
 $grosspay = number_format($grosspay, 2);
 $netpay = number_format($netpay, 2);
 $totaltax = number_format($totaltax,2);
echo \"<table>
 <tr>
 <th colspan=>Paycheck Calculator</th>
 </tr>
 <tr>
 <td>Employee Name</td>
 <td>\"<?php echo \"$employeename\"; ?>\"</td></tr>
 <tr>
 <td>Regular Hours Worked (between 0 and 40)</td>
 <td>$hours</td></tr>
 <tr>
 <td>Overtime Hours Worked(between 0 and 40)</td>
 <td>$overtime</td></tr>
 <tr>
 <td>Regular Pay</td>
 <td>$$regularpay</td></tr>
 <tr>
 <td>Overtime Pay</td>
 <td>$$overtimepay</td>
 </tr>
 <tr>
 <td>Gross Pay</td>
 <td>$grosspay</td></tr>
 <tr>
 <td>Fica Tax Rate</td>
 <td>$ficarate%</td>
 </tr>
 <tr>
 <td>Fica Taxes Withheld</td>
 <td>$ficatax</td>
 </tr>
 <tr>
 <td>State Tax Rate</td>
 <td>$staterate%</td>
 </tr>
 </tr>
 <tr>
 <td>State Taxes Withheld</td>
 <td>$$statetax</td>
 </tr>
 <tr>
 <td>Federal Tax Rate</td>
 <td>$federalrate%</td>
 </tr>
 <tr>
 <td>Federal Tax Withheld</td>
 <td>$federaltax</td>
 </tr>
 <tr>
 <td>Total Taxes</td>
 <td>$totaltax</td>
 </tr>
 </tr>
 <tr>
 <td>Net Pay</td>
 <td>$$netpay</td>
 </tr>
 </td>
 </tr>
 </table>\";
 }
   
 ?>
<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
 <head>
 <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
 <link rel=\"stylesheet\" href=\"css/styles.css\" type=\"text/css\">
 <title>Numbers</title>
 </head>
 <body>
</body>
 </html>
Solution
There is error in the way echo statement is written
you have written the echo statement as follows to print the variable name employeename <td>\"<?php echo \"$employeename\"; ?>\"</td></tr>
The correct way to write is as follows:
<td>$employeename</td></tr>
Use this way to print the employeename in your code and it will print the value not the variable name.




