I have this part here which generates me an array:
$ids_sektor = explode("/",$row['sektori']);
What i need is to echo all those values inside a select option... The html for my selectbox is:
<select id="sektori_pergjegjes" name="sektori_pergjegjes">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
<option value="E">E</option>
</select>
I tried foreach but no success, i guess i'm doing something wrong, of cours ei am, some help please.
It should work as follows:
$row['sektori'] = "12/34/56";
$ids_sektor = explode("/", $row['sektori'];
foreach ($ids_sektor as $id) {
echo "<option>$id</option>
";
}
I'm not sure I understood the question well, but it should be done like that:
<select id="sektori_pergjegjes" name="sektori_pergjegjes">
<?php
foreach($ids_sektor as $item)
{
$id = htmlspecialchars(item);
echo('<option value="' . $id . '">' . $id . '</option>');
}
?>
</select>
You may skip htmlspecialchars()
when you're 100% sure there will be just A/B/C/D/E
in your array.