Request assistance with creating and reading an array

ICHaps

New member
Hello.

May I please request some guidance with regards arrays?
I'm trying to create a very simple job search and application section of my site.
To start with, site asks the user to select which part of the country should searched for or Any Part, then I want it to search the database for available matches relating to the search location or list all results.


ok, So far I've written, following code to collect the search data from the previous form using POST, then compare with what's in the database, and if there's a match, enter it into an array. However for this test, I'm entering both records from the database into the array.
$larea = $_POST["comlocation"];
$count=0;

try {
$conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$results = $conn->query('SELECT * FROM vacancies');
while ($row = $results->fetch()) {
//if ($row['status'] == "Open") {
//if ($row['location'] == $larea or $larea == "Any") {
$joblst_id[$count] = $row['vacencies_id'];
$joblst_title[$count] = $row['jobtitle'];
$joblst_subtitle[$count] = $row['subtitle'];
$joblst_positiontype[$count] = $row['positiontype'];
$joblst_location[$count] = $row['location'];
$joblst_towncity[$count] = $row['towncity'];
$joblst_closingdate[$count] = $row['closingdate'];
$joblst_status[$count] = $row['status'];
$count++;
//}
//}
}
}catch(PDOException $e) {
echo $e;
exit;
}
I'm unsure if my coding is correct, would a member just check through it and let me know if it's ok please?

Then on the second page. I'm struggling with it as it dose not display the array data, and I can't figure out why it's not working, and only showing blanks.

<?
for ($x=0; $x<$count; $x++) { ?>
<div class="col-sm-6 col-lg-4 marketing">
<div class="featured__card border wow fadeInDown" data-wow-duration="1s" data-wow-delay=".1s" onclick="location.href='/Screen/main/job-details.html'">
<div class="featured__card--head">
<div>
<img class="w-100 img-fluid" src="/Screen/main/assets/images/pixner.png" alt="pixner">
</div>
<div>
<h6 class="text-larg text-dark"><?=$joblst_title[$x]?></h6>
<p class="text-primary"><?= $joblst_subtitle[$x] ?></p>
</div>
</div>
</div>
<div class="featured__card--foot">
<a class="" href="#">full time</a>
<a class="" href="z-job-details.html">read more</a>
</div>
</div>
</div>
<?
}
//unset($_SESSION['count']);
?>

I'd be grateful if anyone could please assist me.
Thank you
 
Back
Top