I am trying to allocate options in drop down box using while loop. The options appear blank on the page. No errors shown.
<?php
$dbstate = new DB();
if (!$dbstate->open()) {
die ($dbstate->error());
}
if (!$dbstate->query("SELECT * FROM external_details order by external_id")) {
die ($dbstate->error());
}
?>
<select name="selstate" >
<option value="0">Subject</option>
<?php while ($row = $dbstate->fetchAssoc()) {?>
<option value="<?= $row['external_id']?>">
<?= $row['name']?>
</option>
<?php
}
$dbstate->freeResult();
$dbstate->close();
?>
Either enable the short_open_tags
option in your php.ini
, or change <?=
to <?php echo