I've been developing in PHP for a few years, but one thing I constantly question is whether I should structure my pages like so:
if(getValue('action') == "jobsFilter" && getValue('jobType') == "open")
{
$job->FetchJobs($jobStatus = 1);
foreach($job->result AS $pulledJob)
{
?>
<div class = "openJob panelJob col-xs-12">
<h2><?php echo $pulledJob['jobTitle'] ?></h2>
<a href = "?action=viewJob&jobId=<?php echo $pulledJob['Id'] ?>" class = "viewJobBtn ">View Job</a>
</div>
<?php
}
}else if(getValue('action') == "jobsFilter" && getValue('jobType') == "active")
{
$job->fetchAllJobsAppliedToUser($jobStatus = 1);
foreach($job->result AS $pulledJob)
{
?>
<div class = "openJob panelJob col-xs-12">
<h2><?php echo $pulledJob['jobTitle'] ?></h2>
<a href = "?action=viewJob&jobId=<?php echo $pulledJob['Id'] ?>&jobStatus=1" class = "viewJobBtn ">View Details</a>
</div>
<?php
}
}else if(getValue('action') == "viewJob" && isset($_GET['jobId']))
{
$job->FetchJobs($jobStatus = 1, $jobId = $_GET['jobId']);
foreach($job->result AS $pulledJob)
{
?>
<div class = "viewJob panelJob col-xs-12">
<div class = "pulledJobInfo">
<h2><?php echo $pulledJob['jobTitle'] ?></h2>
<p><?php echo $pulledJob['JobDescription'] ?></p>
</div>
<form method = "post" action = "?action=acceptJob">
<input type = "submit" name = "acceptJobSubmitBtn" class = "acceptJobBtn fullWidthButton ctaButton" value = "Let me help" />
<input type = "hidden" name = "jobId" value = "<?php echo $pulledJob['Id'] ?>" />
</form>
</div>
<?php
}
}
Or whether I should have a separate page, called open-jobs.php for open jobs, closed-jobs.php for closed jobs, etc.
If someone could shed some light on the best solution, that'd be great!