Help to implement the dropdown list. Model:
function region_get(){ $result = $this->mysqli->query("SELECT * FROM t_gs_regions ORDER BY gs_regions_name ASC"); $n=$result->num_rows; for($i=0; $i<$n; $i++) { $row6 = mysqli_fetch_assoc($result); $regions[] = $row6; } return $regions; }
Controller:
$reg = region_get();
View:
<select name="regions_id"> <option value="">ΠΠΈΠ±Π΅ΡΠΈΡΠ΅ ΠΈΠ· ΡΠΏΠΈΡΠΊΠ°</option> <?php foreach ($regions as $r):?> { '<option value=<?=$r['gs_regions_id']?>><?=$r['gs_regions_name']?>'</option>'; } <?php endforeach ?> } else { '<option value="">Π‘ΠΏΠΈΡΠΎΠΊ Π½Π΅Π΄ΠΎΡΡΡΠΏΠ½ΠΈΠΉ</option>'; } ?> </select>
var_dump($regions);
at the end of the model. Is the array full? - MichaelPak$reg
in the controller and$regions
in the view? - MichaelPak