on-internet
← Community

Populate HTML select tag options from query results in CodeIgniter [duplicate]

Stack Overflow ·

This is my simple php html code. <select id="district" name="district"> <option value="">Select district</option> <?php $sql = "SELECT * FROM district"; $result = mysqli_query($sql); while ($row = mysqli_fetch_array($result)) { $district_id = $row['district_id']; $district_name = $row['district_name']; ?> <option value="<?php echo $district_id; ?>"><?php echo $district_name; ?></option> <?php } ?> </select> It's not working. The database is autoloaded. What will be the problem?

Comments

Sign in or sign up to comment and upvote.

No comments yet.