Skip to content

Instantly share code, notes, and snippets.

@qolbu
Last active February 15, 2017 10:17
Show Gist options
  • Save qolbu/b4b1f1d4a9ad687979d21bed5475524c to your computer and use it in GitHub Desktop.
Save qolbu/b4b1f1d4a9ad687979d21bed5475524c to your computer and use it in GitHub Desktop.
populate city from rajaongkir.com API - Opencart
<select name="custom_city_id" id="input-city" class="form-control">
<option value="0"><?php echo $text_none; ?></option>
<?php foreach ($cities as $value) { ?>
<?php if ($value->city_id == $custom_city_id) { ?>
<option value="<?php echo $value->city_id; ?>" selected="selected"><?php echo $value->city_name; ?></option>
<?php } else { ?>
<option value="<?php echo $value->city_id; ?>"><?php echo $value->city_name; ?></option>
<?php } ?>
<?php } ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment