hi can someone help me...
im new PHP leaner.. i want to develop staff movement system. I want to display all record in dbase from table leave mgmt which is supervisor can choose 3 status selection:
1) Approved
2)Pending
3)Rejected
(record display based on direct report supervisor - have 2 supervisor handle 2 diff group)
If supervisor choose 1, system will display all approved staff leave application record from table leave mgmt.
If supervisor choose 2, system will display all pending staff leave application record from table leave mgmt.
If supervisor choose 3, system will display all rejected staff leave application record from table leave mgmt.
[code=php]<?php require_once('C onnections/fmu.php'); ?>
<?php
//initialize the session
if (!isset($_SESSI ON)) {
session_start() ;
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=tru e";
if ((isset($_SERVE R['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_ SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php" ;
if ($logoutGoTo) {
header("Locatio n: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSI ON)) {
session_start() ;
}
$MM_authorizedU sers = "";
$MM_donotChecka ccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($s trUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserNa me)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($User Name, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($User Group, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoT o = "index.php" ;
if (!((isset($_SES SION['MM_Username'])) && (isAuthorized(" ",$MM_authorize dUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_res trictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_S TRING) && strlen($QUERY_S TRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoT o = $MM_restrictGoT o. $MM_qsChar . "accesschec k=" . urlencode($MM_r eferrer);
header("Locatio n: ". $MM_restrictGoT o);
exit;
}
?><?php
$user = $_SESSION['MM_Username'];
mysql_select_db ($database_fmu, $fmu);
$query_Recordse t1 = "SELECT * FROM staff WHERE Staff_ID = '$user'";
$Recordset1 = mysql_query($qu ery_Recordset1, $fmu) or die(mysql_error ());
$row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
$totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);
mysql_select_db ($database_fmu, $fmu);
$query_Recordse t2 = "SELECT * FROM leave_mgmt WHERE Status='Pending '";
$Recordset2 = mysql_query($qu ery_Recordset2, $fmu) or die(mysql_error ());
$row_Recordset2 = mysql_fetch_ass oc($Recordset2) ;
$totalRows_Reco rdset2 = mysql_num_rows( $Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>leave req</title>
<style type="text/css">
<!--
.style2 {
font-size: 18px;
font-weight: bold;
}
.style4 {font-family: "Times New Roman", Times, serif}
.style5 {color: #000000}
.style6 {font-size: 12px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="" >
<table width="690" border="0" cellspacing="0" cellpadding="0" >
<tr>
<th scope="row" bgcolor="#3399F F" height="40"><di v align="left" class="style2"> <span class="style4"> Leave Request</span></div></th>
</tr>
<tr>
<th scope="row" ><span class="style4"> </span></th>
</tr>
<tr>
<th scope="row"><di v align="left" class="style4"> <br/><?php echo $row_Recordset1['Staff_Name']; ?></div></th>
</tr>
<tr>
<th scope="row"><di v align="left" class="style4"> <br/><?php echo $row_Recordset1['Designation']; ?> (<?php echo $row_Recordset1['Staff_ID']; ?>)</div></th>
</tr>
<tr>
<th scope="row"><di v align="left"><b r/>
<span class="style6 style4">Click on the requestor's name link to approve or deny the request. To view all requests or previously approved/denied requests, use the Show Requests by Status and select the Refresh button. </span>
<!-- End HTML Area -->
</div></th>
</tr>
<tr>
<th scope="row">&nb sp;</th>
</tr>
<tr>
<th scope="row"><di v align="left">Sh ows requests by status
<select name="select">
<option value="Approved ">Approved</option>
<option value="Pending" >Pending</option>
<option value="Rejected ">Rejected</option>
</select>
<input name="refresh" type="submit" id="refresh" value="Refresh" />
</div></th>
</tr>
</table>
<br />
<span class="style4">
<?php
if($totalRows_R ecordset2 == 0) {
?>
<script language="javas cript">
document.write( "There is no pending leave request to be approved");
</script>
<?php
}
else
{
?>
<script language="javas cript">
document.write( "There is pending leave request to be approved.");
</script>
<?php
}
if($totalRows_R ecordset2 != 0) {
?>
</span>
<table width="590" border="0">
<tr>
<?php
$search=$_POST["search"];
$result = mysql_query("SE LECT * FROM leave_mgmt");
echo "<table border='1'>
<tr><br/>
<th width ='50' align='left' bgcolor='#3399F F'>ID</th>
<th width ='100' align='left' bgcolor='#3399F F'>Apply Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>Begin Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>End Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>Total Days</th>
<th width ='100' align='left' bgcolor='#3399F F'>Leave Type</th>
<th width ='100' align='left' bgcolor='#3399F F'>Reason</th>
<th width ='100' align='left' bgcolor='#3399F F'>Status</th>
</tr>";
while($row=mysq l_fetch_array($ result))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</a></td>";
echo "<td>" . $row['Apply_Date'] . "</td>";
echo "<td>" . $row['Begin_Date'] . "</td>";
echo "<td>" . $row['End_Date'] . "</td>";
echo "<td>" . $row['Total_Days'] . "</td>";
echo "<td>" . $row['Leave_Type'] . "</td>";
echo "<td>" . $row['Reason'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "</tr>";
}
echo "</table>";?>
</tr>
</table>
<span class="style4">
<?php } ?>
</form>
<table width="690" border="0">
<tr><br/>
<td width="58"><br/>Go to: </td>
<td width="522"><br/><a href="LeaveMana gement.php" class="style5"> Leave Management Menu</a></td>
</tr>
<tr>
<td> </td>
<td><br/><a href="EmpSelfSv cmenu.php" class="style5"> Employee Self Service Menu</a> </td>
</tr>
<tr>
<td> </td>
<td><br/>
<a href="<?php echo $logoutAction ?>" class="style5"> Log out</a> </tr>
</table>
</body>
</html>
<?php
mysql_free_resu lt($Recordset1) ;
mysql_free_resu lt($Recordset2) ;
?>[/code]
im new PHP leaner.. i want to develop staff movement system. I want to display all record in dbase from table leave mgmt which is supervisor can choose 3 status selection:
1) Approved
2)Pending
3)Rejected
(record display based on direct report supervisor - have 2 supervisor handle 2 diff group)
If supervisor choose 1, system will display all approved staff leave application record from table leave mgmt.
If supervisor choose 2, system will display all pending staff leave application record from table leave mgmt.
If supervisor choose 3, system will display all rejected staff leave application record from table leave mgmt.
[code=php]<?php require_once('C onnections/fmu.php'); ?>
<?php
//initialize the session
if (!isset($_SESSI ON)) {
session_start() ;
}
// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=tru e";
if ((isset($_SERVE R['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
$logoutAction .="&". htmlentities($_ SERVER['QUERY_STRING']);
}
if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
//to fully log out a visitor we need to clear the session varialbles
$_SESSION['MM_Username'] = NULL;
$_SESSION['MM_UserGroup'] = NULL;
$_SESSION['PrevUrl'] = NULL;
unset($_SESSION['MM_Username']);
unset($_SESSION['MM_UserGroup']);
unset($_SESSION['PrevUrl']);
$logoutGoTo = "index.php" ;
if ($logoutGoTo) {
header("Locatio n: $logoutGoTo");
exit;
}
}
?>
<?php
if (!isset($_SESSI ON)) {
session_start() ;
}
$MM_authorizedU sers = "";
$MM_donotChecka ccess = "true";
// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($s trUsers, $strGroups, $UserName, $UserGroup) {
// For security, start by assuming the visitor is NOT authorized.
$isValid = False;
// When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
// Therefore, we know that a user is NOT logged in if that Session variable is blank.
if (!empty($UserNa me)) {
// Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
// Parse the strings into arrays.
$arrUsers = Explode(",", $strUsers);
$arrGroups = Explode(",", $strGroups);
if (in_array($User Name, $arrUsers)) {
$isValid = true;
}
// Or, you may restrict access to only certain users based on their username.
if (in_array($User Group, $arrGroups)) {
$isValid = true;
}
if (($strUsers == "") && true) {
$isValid = true;
}
}
return $isValid;
}
$MM_restrictGoT o = "index.php" ;
if (!((isset($_SES SION['MM_Username'])) && (isAuthorized(" ",$MM_authorize dUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) {
$MM_qsChar = "?";
$MM_referrer = $_SERVER['PHP_SELF'];
if (strpos($MM_res trictGoTo, "?")) $MM_qsChar = "&";
if (isset($QUERY_S TRING) && strlen($QUERY_S TRING) > 0)
$MM_referrer .= "?" . $QUERY_STRING;
$MM_restrictGoT o = $MM_restrictGoT o. $MM_qsChar . "accesschec k=" . urlencode($MM_r eferrer);
header("Locatio n: ". $MM_restrictGoT o);
exit;
}
?><?php
$user = $_SESSION['MM_Username'];
mysql_select_db ($database_fmu, $fmu);
$query_Recordse t1 = "SELECT * FROM staff WHERE Staff_ID = '$user'";
$Recordset1 = mysql_query($qu ery_Recordset1, $fmu) or die(mysql_error ());
$row_Recordset1 = mysql_fetch_ass oc($Recordset1) ;
$totalRows_Reco rdset1 = mysql_num_rows( $Recordset1);
mysql_select_db ($database_fmu, $fmu);
$query_Recordse t2 = "SELECT * FROM leave_mgmt WHERE Status='Pending '";
$Recordset2 = mysql_query($qu ery_Recordset2, $fmu) or die(mysql_error ());
$row_Recordset2 = mysql_fetch_ass oc($Recordset2) ;
$totalRows_Reco rdset2 = mysql_num_rows( $Recordset2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dt d">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>leave req</title>
<style type="text/css">
<!--
.style2 {
font-size: 18px;
font-weight: bold;
}
.style4 {font-family: "Times New Roman", Times, serif}
.style5 {color: #000000}
.style6 {font-size: 12px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="" >
<table width="690" border="0" cellspacing="0" cellpadding="0" >
<tr>
<th scope="row" bgcolor="#3399F F" height="40"><di v align="left" class="style2"> <span class="style4"> Leave Request</span></div></th>
</tr>
<tr>
<th scope="row" ><span class="style4"> </span></th>
</tr>
<tr>
<th scope="row"><di v align="left" class="style4"> <br/><?php echo $row_Recordset1['Staff_Name']; ?></div></th>
</tr>
<tr>
<th scope="row"><di v align="left" class="style4"> <br/><?php echo $row_Recordset1['Designation']; ?> (<?php echo $row_Recordset1['Staff_ID']; ?>)</div></th>
</tr>
<tr>
<th scope="row"><di v align="left"><b r/>
<span class="style6 style4">Click on the requestor's name link to approve or deny the request. To view all requests or previously approved/denied requests, use the Show Requests by Status and select the Refresh button. </span>
<!-- End HTML Area -->
</div></th>
</tr>
<tr>
<th scope="row">&nb sp;</th>
</tr>
<tr>
<th scope="row"><di v align="left">Sh ows requests by status
<select name="select">
<option value="Approved ">Approved</option>
<option value="Pending" >Pending</option>
<option value="Rejected ">Rejected</option>
</select>
<input name="refresh" type="submit" id="refresh" value="Refresh" />
</div></th>
</tr>
</table>
<br />
<span class="style4">
<?php
if($totalRows_R ecordset2 == 0) {
?>
<script language="javas cript">
document.write( "There is no pending leave request to be approved");
</script>
<?php
}
else
{
?>
<script language="javas cript">
document.write( "There is pending leave request to be approved.");
</script>
<?php
}
if($totalRows_R ecordset2 != 0) {
?>
</span>
<table width="590" border="0">
<tr>
<?php
$search=$_POST["search"];
$result = mysql_query("SE LECT * FROM leave_mgmt");
echo "<table border='1'>
<tr><br/>
<th width ='50' align='left' bgcolor='#3399F F'>ID</th>
<th width ='100' align='left' bgcolor='#3399F F'>Apply Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>Begin Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>End Date</th>
<th width ='100' align='left' bgcolor='#3399F F'>Total Days</th>
<th width ='100' align='left' bgcolor='#3399F F'>Leave Type</th>
<th width ='100' align='left' bgcolor='#3399F F'>Reason</th>
<th width ='100' align='left' bgcolor='#3399F F'>Status</th>
</tr>";
while($row=mysq l_fetch_array($ result))
{
echo "<tr>";
echo "<td>" . $row['ID'] . "</a></td>";
echo "<td>" . $row['Apply_Date'] . "</td>";
echo "<td>" . $row['Begin_Date'] . "</td>";
echo "<td>" . $row['End_Date'] . "</td>";
echo "<td>" . $row['Total_Days'] . "</td>";
echo "<td>" . $row['Leave_Type'] . "</td>";
echo "<td>" . $row['Reason'] . "</td>";
echo "<td>" . $row['Status'] . "</td>";
echo "</tr>";
}
echo "</table>";?>
</tr>
</table>
<span class="style4">
<?php } ?>
</form>
<table width="690" border="0">
<tr><br/>
<td width="58"><br/>Go to: </td>
<td width="522"><br/><a href="LeaveMana gement.php" class="style5"> Leave Management Menu</a></td>
</tr>
<tr>
<td> </td>
<td><br/><a href="EmpSelfSv cmenu.php" class="style5"> Employee Self Service Menu</a> </td>
</tr>
<tr>
<td> </td>
<td><br/>
<a href="<?php echo $logoutAction ?>" class="style5"> Log out</a> </tr>
</table>
</body>
</html>
<?php
mysql_free_resu lt($Recordset1) ;
mysql_free_resu lt($Recordset2) ;
?>[/code]