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.)
Payroll System image
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)
The code is real mess. On top of my head and first mistake which I spot:
$empID=$_POST["empID"];
after that, several rows bellow you show the form and than submit that form. on that form you have
<input type='hidden' name='empID' value='".$empID."'>
I presume you end to that page via $_GET
request, because otherwise you can pass one of your other checks elseif ($_GET["k"]==41)
. So, if I'm right with that, than you didn't have initial $_POST["empID"]
, so your $empID
variable will be empty.
In general why did you mess so much $_GET
and $_POST
and not stick one one of them?
hint one of the easiest way to check above is to echo the $empID
or the query
UPDATE: (removing my previous answer as it's not correct)
Try printing the query, and run in manually. Then post the result back here so we can tell you more.
Ok, remove the comma before FROM - "b.tx," should be "b.tx"
精彩评论