// 连接数据库
require './includes/connect.class.php';
$conn = Connect::getInstance();
// 获取数据
$res = $conn->fetchAll("SELECT * FROM `b_sale` UNION ALL SELECT * FROM `b_lend` ");
if (isset($_GET['action']) && $_GET['action'] == 'sale') {
// 按销量排序
array_multisort(array_column($res, 'num'), SORT_ASC, $res);
} elseif (isset($_GET['action']) && $_GET['action'] == 'price') {
// 按价格排序
array_multisort(array_column($res, 'price'), SORT_ASC, $res);
}