I'm trying to add data from database to 2-dimensional array and then unpacking.
This function is in a folder named imsConnection.php
function getCurrency() {
global $cn;
$sql = "select * from Currency";
$res = mysqli_query($cn, $sql);
$a = array();
if (mysqli_num_rows($res) > 0) {
while ($row = mysqli_fetch_array($res)) {
$a[] = array($row['currencyID'], $row['currencyName']);
}
}
return $a;
}
And to unpack it into drop box:
<select name="drpCurrency" required>
<?php
require_once("imsConnection.php");
$a = getCurrency();
foreach($a as $i) {
echo "<option value='$i'>$a[$i]</option>";
}
?>
</select>
$a[$i]as$iis already the element - just echo the$i['currencyName']