I was try to get CompanyID
and JobListingID
from the while loop so after clicking apply button it can pass the data to another table called application, but somehow it only pass the latest JobListingID
with the CompanyID
from the joblisting table to the application How am I suppose to do to make it pass the data that I need?
<?php
include ("Jobseeker_session.php");
require_once('connect.php');
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<html>
<head>
<title>Job Seeker Website</title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link href='https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css' rel='stylesheet'>
</head>
<body>
<div class="sidebar">
<div class="logo-details">
<i class='#' ></i>
<span class="logo_name">Job Seekeer</span>
</div>
<ul class="nav-links">
<li>
<a href="JobSeekerProfile.php" >
<i class='bx bxs-user-detail' ></i>
<span class="links_name">Profile</span>
</a>
</li>
<li>
<a href="JobSeekerAboutUs.php" >
<i class='bx bxs-user-account' ></i>
<span class="links_name">About Us</span>
</a>
</li>
<li>
<a href="JobSeekerJobListing.php">
<i class='bx bx-list-ul' ></i>
<span class="links_name">Job Listing</span>
</a>
</li>
<li>
<a href="JobSeekerCompanyListing.php">
<i class='bx bx-list-ul' ></i>
<span class="links_name">Company Listing</span>
</a>
</li>
<li>
<a href="JobSeekerFavourite.php">
<i class='bx bxs-bookmark' ></i>
<span class="links_name">Favourite</span>
</a>
</li>
<li>
<a href="JobSeekerApplication.php">
<i class='bx bxs-business'></i>
<span class="links_name">Application</span>
</a>
</li>
<li>
<a href="JobSeekerReportHistory.php">
<i class='bx bxs-time'></i>
<span class="links_name">History Report</span>
</a>
</li>
<li>
<a href="JobSeekerMessage.php">
<i class='bx bxs-chat' ></i>
<span class="links_name">Message</span>
</a>
</li>
<li>
<a href="JobSeekerResume.php">
<i class='bx bx-paperclip'></i>
<span class="links_name">Resume</span>
</a>
</li>
<li class="log_out">
<a href="#">
<i class='bx bx-log-out'></i>
<span class="links_name">Log out</span>
</a>
</li>
</ul>
</div>
<nav>
<div class="sidebar-button">
<i class='bx bx-menu sidebarBtn'></i>
<span class="dashboard">Dashboard</span>
</div>
<div class="search-box">
<input type="text" placeholder="Search...">
</div>
<div class="profile-details">
<span class="admin_name"></span>
</div>
</nav>
<section class="home-section">
<div class="home-content">
<div class="all-boxes">
<div class="title">Job Listing</div>
<div class="applicant-boxes">
<form method="post">
<div class="listing-boxes">
<div class="left">
<?php
$sql = "select * from joblisting";
$result = mysqli_query($connect,$sql);
while($row = mysqli_fetch_assoc($result))
{
$eee = $row['JobListingID'];
$new = $row['CompanyID'];
$sql2 = "select * from company_info WHERE CompanyID = '$new'";
$result2 = mysqli_query($connect,$sql2);
$row2 = mysqli_fetch_assoc($result2);
if(is_array($row2)){
?>
<div class="job-card">
<div class="img">
<img src="<?php echo $row2["CompanyLogo"]; ?>">
</div>
<div class="content">
<h2 ><a href="JobSeekerJobDescription.php?jobid=<?php echo $eee;?>"><?php echo $row["JobTitle"]; ?></a></h2>
<p><b>Company:</b> <?php echo $row2["CompanyName"]; ?><?php echo $new;?></p>
<p><b>Location:</b> <?php echo $row["JobLocation"]; ?><?php echo $eee;?><?php echo $new;?></p>
<p><b>Salary:</b> <?php echo $row["JobSalary"]; ?><?php echo $eee;?></p>
<div class="action">
<button type="submit" class="btn btn-primary" name="apply">Apply<?php echo $eee;?><?php echo $new;?></button>
<button type="submit" class="btn btn-primary" name="favourite">Add To Favourite<?php echo $eee;?><?php echo $new;?></button>
<a href="JobSeekerReport.php?joblistingid=<?php echo $eee;?>">Report Job</a>
</div>
</div>
</div>
<?php
}
}
?>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
</div>
</body>
</html>
<?php
if(isset($_POST['apply']))
{date_default_timezone_set("Asia/Kuala_Lumpur");
$date=date('d/m/Y H:i:s');
$query = "INSERT INTO application(DateApplied,ApplicationStatus,Job_SeekerID,CompanyID,JobListingID)
VALUES('$date','In Progress','$jobseekerid','$new','$eee')";
$result = mysqli_query($connect,$query);
}
?>
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>