I'm trying to use PDO
for a SELECT
Option, this is my functions.php
code:
<?php
class Benefits
{
public function fetch_all()
{
global $pdo;
$benfitssql = $pdo->query('SELECT * FROM lkup_benefits');
//$benfitssql->execute();
while ($row = $benfitssql->fetch(PDO::FETCH_ASSOC))
{
$ops.= "<option value='" . $row['BenefitOption'] . "'>"
. $row['Benfits'] . "</option>";
}
}
}
?>
This is my main page:
<label>Benefit Type</label>
<select class="select2_category form-control" data-placeholder="Choose a Category" tabindex="1" id="benefittype" name="benefittype">
<?php echo $ops; ?>
</select>
When I select the SELECT
Option, it opens with no records, why would this be, what have I missed?