I have the following simple function
function getAllJobs($userType)
{
if ($userType == 2) {
$sql = "SELECT * FROM jobs";
$stmnt = $db->prepare($sql);
$stmnt->execute();
return $stmnt->fetchAll();
} else {
return false;
}
}
The above produces the following page, via a simple foreach() loop:
WHAT I AM TRYING TODO
When a user ALREADY applied for a job displayed, I want the blue "Apply" button to change to something like "Applied"
Now I believe this can / should be achieved by changing the mysql query in my function above.
Here is a look at my database:
WHAT I TRIED
I tried changing my db query in getAllJobs() function as follows:
SELECT jobs.*, bids.*
FROM bids
INNER JOIN jobs on jobs.jobID = bids.jobID
WHERE bids.jobID = jobs.jobID
The problem with the above query is it only returns the jobs which the specific user applied for.
Again what I am trying to achieve is to display ALL jobs where the user Already applied for a job change button text to "Applied" or something similar. The below image serves as an example of what I am trying to achieve.
Any help or advice much appreciated. Kindly drop me a comment should you need more information or code.
EDIT:
I should probably add my foreach code here:
<?php
foreach ($jobs as $job){
$description = $job['description'];
$jobDescription = substrwords($description, 30);
echo '<div>' . $job['headline'] . '</div>';
echo '<div>' . $jobDescription . '</div>';
echo '<div>' . $job['datePosted'] . '</div>';
echo '<div>' . $job['amount'] . '</div>';
echo '<div>' . $job['location'] . '</div>';?>
<?php
echo '<div class="jobPosting">';
?>
<input type="text" value="apply" name="action" style="display: none" />
<button name="placeBid" type="submit" class="btn btn-primary" value="<?php echo $job['jobID']; ?>">Apply</button>
<?php echo '</div>
<hr style="border: dotted thin #eeefff" />';
echo '</div>';
}//foreach


