0
我有这样的代码,在WordPress的编码:比较数据库的价格和选择价格最低
<?php
global $product;
global $wpdb;
$locations = get_the_terms($product->ID, 'pa_location');
foreach ($locations as $locationz) {
$location = $locationz->name;
}
$sql = "SELECT * FROM rates WHERE location = '" . $location . "';";
$query = $wpdb->get_results($sql);
foreach ($query as $price) {
$regularprice = $price->fareprice;
}
?>
现在,我的问题是选择使用,其中有4个相同位置的位置列中的最低价格。
我知道我可以使用min();
但是如何将$regularprices
存储在数组上并使用min();
来选择最低价格?
没关系,我得到了它已经 “' –
Romee648