I am fetching the records from the database using the following code snippet:
if($pdo)
{
$stmt = $pdo->query('SELECT ID,Province,City,Position,Locale FROM jobs');
$result=$stmt->fetchAll(PDO::FETCH_ASSOC);
print("<pre>".print_r($result,true)."</pre>");
}
I am getting the array :
I would like to retrieve the values using for each loop and display on the website:
Province name
city name:
position name1:
position name 2:
province name
city name:
Position name 3:
Position name 4:
I Have written the code :
<?foreach($result as $key=>$val):?>
<div class='r-wr'>
<h2 class="region-heading"><?=$key?></h2>
<?foreach($val as $city=>$result):?>
<div class='c-wr'>
<h3 class="city-heading"><?=$city?></h3>
<?foreach($result as $pos_key=>$position):?>
<div class="pstn-btn" position-id="<?=$pos_key;?>"><?=$position;?></div><br>
<?endforeach;?>
</div>
<?endforeach;?>
</div>
<?endforeach;?>
can anyone please help me how to write the for each loop to get the record values.
Thanks