html - Call php file to return an array, and load it into a combo box -
i have index.php. want call function in load_data.php return array. want load array combox box on index.php. can me started on this? i'm brand new php , trying head around it.
you can use similar this:
load_data.php
function get_data() { // may want load data db // hint return array('key1' => 'value 1', 'key2' => 'value 2'); }
and in main file:
<select name="myselect"> <?php include 'load_data.php'; $data = get_data(); foreach($data $key => $value) { echo '<option value="'.$key.'">'.$value.'</option>'; } ?> </select>
Comments
Post a Comment