I have this problem on my payroll processing system.
Below the area where the data are added is a table where the data added into the pay table are shown (except for the empID since the payroll details shown on the table must be from those that are associated to the employee that was selected.)
Please refer to the link above to see image to further understand what’s written below.
*[A]*is where the user selects which employee’s payroll details be updated. After selecting the radio button and clicking the “Update Payroll Details” button, the user shall be brought to the Update Payroll Details page which is B.
*[B]*The upper part is where the user enters all the payroll details associated to the employee selected. Once the user clicks save the data shall be added to the database (pay table) and these details shall be shown on the table located below the input area.
However, although I have data in my pay table it wouldn’t seem to display on the table below that’s why the message shows “No Records Found”. Here is my code for the entire Update Payroll Data page:
elseif ($_GET["k"]==41)
{
session_start();
if (isset($_SESSION["uname"]))
{
$empID=$_POST["empID"];
$aBulan=0; $aPetsa=0; $aTuig=0; $tuigYana=date("Y"); $tuigHadto=$tuigYana-5;
$anoBulan=array("January","February","March","April","May","June","July","August","September","October","November","December");
if ($_POST["sButton"]=="Update Payroll Details")
{
$anoSulod ="Payroll Details<hr>";
$anoSulod.="<form method='post' action='logged.php?k=42'>";
$anoSulod.="<input type='hidden' name='empID' value='".$empID."'>";
$anoSulod.="<table>";
$anoSulod.=" <tr><td>Name of employee : </td><td>".accessDatabase::hinoEmployee($empID)."</td></tr>";
$anoSulod.=" <tr>";
$anoSulod.=" <td>For the month ending : </td>";
$anoSulod.=" <td>";
// Kanan month ini dinhi
$anoSulod.=" <select name='bBulan'>";
for ($bulan=1; $bulan<=12; $bulan++)
{
if ($bulan==$aBulan) $anoSulod.=" <option value='".$bulan."' selected>".$anoBulan[$bulan-1];
else $anoSulod.=" <option value='".$bulan."'>".$anoBulan[$bulan-1];
}
$anoSulod.=" </select> ";
// Kanan year ini dinhi
$anoSulod.=" <select name='bTuig'>";
for ($tuig=$tuigYana; $tuig>=$tuigHadto; $tuig--)
{
if ($tuig==$aTuig) $anoSulod.=" <option value='".$tuig."' selected>".$tuig;
else $anoSulod.=" <option value='".$tuig."'>".$tuig;
}
$anoSulod.=" </select>";
$anoSulod.=" </td>";
$anoSulod.=" <tr>";
$anoSulod.=" <tr><td>Basic Salary : PhP</td><td><input type='text' name='bs'></td></tr>";
$anoSulod.=" <tr><td>PERA/ACA : PhP</td><td><input type='text' name='pa'></td></tr>";
$anoSulod.=" <tr><td>PAIC : PhP</td><td><input type='text' name='pc'></td></tr>";
$anoSulod.=" <tr><td>REL : PhP</td><td><input type='text' name='rl'></td></tr>";
$anoSulod.=" <tr><td>GSIS Premium/Loans : PhP</td><td><input type='text' name='gs'></td></tr>";
$anoSulod.=" <tr><td>HDMF Premium/Loans : PhP</td><td><input type='text' name='hd'></td></tr>";
$anoSulod.=" <tr><td>Coop Loans : PhP</td><td><input type='text' name='cl'></td></tr>";
$anoSulod.=" <tr><td>Union Dues : PhP</td><td><input type='text' name='ud'></td></tr>";
$anoSulod.=" <tr><td>Withholding Tax : PhP</td><td><input type='text' name='tx'></td></tr>";
$anoSulod.=" <tr><td colspan='2'><hr></tr>";
$anoSulod.=" <tr><td colspan='2'><input type='submit' value='Save'></tr>";
$anoSulod.=" <tr><td colspan='2'><hr></tr>";
$anoSulod.=" <tr>";
$anoSulod.=" <td colspan='2'>";
$anoSulod.=" <table border='1'>";
$anoSulod.=" <caption>Payroll Details</caption>";
$anoSulod.=" <tr>";
$anoSulod.=" <td> </td>";
$anoSulod.=" <td>Pay period</td>";
$anoSulod.=" <td>Basic Salary</td>";
$anoSulod.=" <td>PERA/ACA</td>";
$anoSulod.=" <td>PAIC</td>";
$anoSulod.=" <td>REL</td>";
$anoSulod.=" <td>GSIS Premium/Loans</td>";
$anoSulod.=" <td>HDMF Premium/Loans</td>";
$anoSulod.=" <td>Coop Loans</td>";
$anoSulod.=" <td>Union Dues</td>";
$anoSulod.=" <td>Withholding Tax</td>";
$anoSulod.=" </tr>";
$k="select b.payID, a.empname, date_format(b.date,'%M %Y') as date, b.bs, b.pa, b.pc, b.rl, b.gs, b.hd, b.cl, b.ud, b.tx, from emp a, pay b where a.empID=b.empID and a.empID=".$empID;
$q=mysql_query($k);
if (mysql_num_rows($q)>0)
{
while ($akonRows=mysql_fetch_array($q))
{
$anoSulod.=" <tr>";
$anoSulod.=" <td><input type='radio' name='payID' value='".$akonRows["payID"]."'></td>";
$anoSulod.=" <td>".$akonRows["date"]."</td>";
$anoSulod.=" <td>".$akonRows["bs"]."</td>";
$anoSulod.=" <td>".$akonRows["pa"]."</td>";
$anoSulod.=" <td>".$akonRows["pc"]."</td>";
$anoSulod.=" <td>".$akonRows["rl"]."</td>";
$anoSulod.=" <td>".$akonRows["gs"]."</td>";
$anoSulod.=" <td>".$akonRows["hd"]."</td>";
$anoSulod.=" <td>".$akonRows["cl"]."</td>";
$anoSulod.=" <td>".$akonRows["ud"]."</td>";
$anoSulod.=" <td>".$akonRows["tx"]."</td>";
$anoSulod.=" </tr>";
}
}
else
{
$anoSulod.=" <tr>";
$anoSulod.=" <td colspan='11' align='center'>No records found</td>";
$anoSulod.=" </tr>";
}
$anoSulod.=" </table>";
$anoSulod.=" </td>";
$anoSulod.=" </tr>";
$anoSulod.="</table>";
$anoSulod.="</form>";
$kadamoTD=2;
}
}
}
Please help. I really can’t figure out what went wrong. Please do… Thanks so much!
Add the error checking for every
mysql_query. At least make a call like:mysql_query($k) or die(mysql_error());Was: Don’t expect that PHP functions (e.g.
date_format) will work inside the SQL query. (Comments say date_format is a MySQL function too)