It looks like this:
and this is what I have tried so far:
<?php
require ('includes/config.php');
// if not logged in redirect to login
if ($user->is_logged_in())
{
}
else
{
header('Location: login.php');
}
$title = "Approve leaves";
if($_SESSION["admin"] == 0){
$page = date('F');
$page = lcfirst($page);
header("Location: $page.php");
}
require ('layout/header.php');
?>
<?php
if(isset($_POST['submit'])){
$count = count($_POST);
$count = $count -1;
for($l = 0; $l < $count; $l++){
echo $_POST[$l];
$result = mysql_query("select name, surname from employee where employee_ID = $id");
while ($row = mysql_fetch_assoc($result)) {
$employee[] = $row;
}
}
}
$i = 0;
$query = "SELECT * from absences WHERE approved = 0";
$result = mysql_query("$query");
while ($row = mysql_fetch_assoc($result)) {
$unapproved[] = $row;
$i++;
}
?>
<div class="container">
<div class="row">
<div class="col-xs-12 col-sm-8 col-md-6 col-sm-offset-2 col-md-offset-3">
<form role="form" method="post" action="" id="form">
<h2><?php echo $title ?></h2>
<?php
$page = date('F');
$page = lcfirst($page);
echo "<p><a href='$page.php'>Back</a></p>";
?>
<hr>
<?php
if($i == 0){
echo "<h3>No unapproved leaves.</h3>";
}else{
echo '<table class="table table-striped table-hover">';
echo '<thead>';
echo '<th>';
echo 'Start';
echo '</th>';
echo '<th>';
echo 'End';
echo '</th>';
echo '<th>';
echo 'Employee';
echo '</th>';
echo '<th>';
echo 'Approve';
echo '</th>';
echo '</thead>';
echo '<tbody>';
for($j =0; $j < $i; $j++){
echo '<tr>';
echo '<td>';
echo $unapproved[$j]['start'];
echo '</td>';
echo '<td>';
echo $unapproved[$j]['end'];
echo '</td>';
echo '<td>';
$id = $unapproved[$j]['employee_FK'];
$result = mysql_query("select name, surname from employee where employee_ID = $id");
while ($row = mysql_fetch_assoc($result)) {
$employee[] = $row;
}
echo $employee[0]['name'], " ", $employee[0]['surname'];
echo '</td>';
echo '<td>';
echo "<input type='checkbox' name='$j' value='1' id='$j'>";
echo '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
?>
<input type="submit" name="submit" value="Submit" class="btn" >
</div>
</div>
</form>
</div>
<?php
require ('layout/footer.php');
?>
The problem is that I only have the order of the checkboxes and if they are approved or not. I need to get the absence_ID from the MySQL table. In order to do that I need the employee_ID, so probably something like this:
select absences_ID from absences wehere employee_ID = $employee_Fk
But how do I get the employee_FK with the results from the checkboxes? I dont really wanna send the employee_FK in the name of the form.
Aucun commentaire:
Enregistrer un commentaire