最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Fetch data from database with dropdown selected option

programmeradmin4浏览0评论

I have a custom database table, location( id, country, city, latitude, longtitude )

2 page : country.php(display all countries) and country detail.php (display cities for each country in the dropdown) that my code in the pic work perfectly

But I want to display latitude and longtitude for city selected option in the field text

<select name="state" id="address" class="form-control">
Global $wpdb;
$code = get_query_var('country');
$result = $wpdb->get_results ( "SELECT city, latitude FROM location 
WHERE country = '$code'");

foreach($result as $row) {
$city=$row->city;
?>
 <option value="<?php echo $city; ?>"><?php echo $city; ?</option>
<?php
}
?>
</select>  
发布评论

评论列表(0)

  1. 暂无评论