[SOLVED] checkbox value
Posted: Tue Aug 17, 2004 4:15 am
check this code:
I got the display like I want it to be.. But now how to pass the value of the checkbox.
When the approved button is clicked. I want the value of status in table leave to change from pending review to approved.
When the not approved button is clicked. I want the value of status in table leave to change from pending review to not approved.
Just want to know what variable should I pass to the update query to update data in table leave?
Code: Select all
<?php
session_start();
include("database.php");
$user=addslashes($_SESSION[username]);
$query="SELECT * FROM `leave` a INNER JOIN `employee` b ON b.`StaffNo` = a.`Super` WHERE b.`username` = '$user'AND a.`Status` = 'Pending
Review'";
$result=mysql_query($query) or die(mysql_error());
?>
<div align="left">
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td align="left" valign="bottom" width="2%"
bgcolor="lightskyblue" valign="TOP" marginwidth="12" marginheight="12">
</td>
<td align="left" valign="bottom" width="25%"
bgcolor="lightskyblue" valign="TOP" marginwidth="12" marginheight="12">
<b>NAMA</b>
</td>
<td align="left" valign="top" width="18%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<b>REF. ID</b>
</td>
<td align="left" valign="top" width="17%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<b>TARIKH PERMOHONAN</b>
</td>
<td align="left" valign="top" width="20%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<b>TARIKH CUTI</b>
</td>
<td align="left" valign="top" width="18%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<b>STATUS</b>
</td>
</tr>
</table>
</div>
<?
while ($row = mysql_fetch_array($result))
{
$refid=$row["RefID"];
$nama = $row["Nama"];
$jawatan = $row["Jawatan"];
$jenis = $row["Jenis"];
$mula = $row["DateMula"];
$tamat = $row["DateTamat"];
$mohon = $row["DateMohon"];
$refid = $row["RefID"];
$status = $row["Status"];
$access = $row["AccType"];
$ack_by = $row["EmpName"];
echo"<form action=leave_app_2.php?$approved method=POST>";
?>
<div align="left">
<table border="0" cellpadding="2" cellspacing="1" width="100%">
<tr>
<td align="left" valign="bottom" width="2%"
bgcolor="lightskyblue" valign="TOP" marginwidth="12" marginheight="12">
<?echo"<input type=checkbox name=approved[] value=$refid>";?>
</td>
<td align="left" valign="bottom" width="25%"
bgcolor="lightskyblue" valign="TOP" marginwidth="12" marginheight="12">
<?echo"$nama";?>
</td>
<td align="left" valign="top" width="18%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<?echo"$refid";?>
</td>
<td align="left" valign="top" width="17%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<?echo"$mohon";?>
</td>
<td align="left" valign="top" width="20%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<?echo"$mula";?> hingga <?echo"$tamat"?>
</td>
<td align="left" valign="top" width="18%"
bgcolor="lightskyblue" marginwidth="12" marginheight="12">
<?echo"$status";?>
</td>
</tr>
</table>
</div>
<?
}
?>
<input type="hidden" name="statusby" value="<? echo $ack_by; ?>" >
<br>
<div align="left">
<table width="100%">
<tr>
<td align="right" width="50%">
<input type="submit" value="APPROVED" name="app">
</td>
<td align="left" width="50%">
<input type="submit" value="NOT APPROVED" name="notapp">
</td>
</tr>
</table>
</div>
</form>
?>When the approved button is clicked. I want the value of status in table leave to change from pending review to approved.
When the not approved button is clicked. I want the value of status in table leave to change from pending review to not approved.
Just want to know what variable should I pass to the update query to update data in table leave?