// 1. 【智能判断价格与单位】
$price = 0;
$unit = '';
if (!empty($r['qijia']) && $r['qijia'] > 0) {
// 如果有起价(qijia),说明是酒店,显示 元/间
$price = $r['qijia'];
$unit = '元/间';
} elseif (!empty($r['mpjg']) && $r['mpjg'] > 0) {
// 如果有门票价格(mpjg),说明是景点,单位隐藏为空
$price = $r['mpjg'];
$unit = '';
}
if (empty($price) || $price == '0.00') {
$show_price = ''; // 价格为空或0,直接不显示
} else {
$show_price = '¥
'.$price.''.$unit;
}
// 2. 【智能判断地址类型】
$address_html = '';
if (!empty(trim($r['jddz']))) {
// 如果有 jddz,显示酒店地址
$address_html = '
酒店地址:'.$r['jddz'].'';
} elseif (!empty(trim($r['jdxxdz']))) {
// 如果有 jdxxdz,显示景点地址
$address_html = '
景点地址:'.$r['jdxxdz'].'';
}
// 如果上面两个都是空的,$address_html 就是空的,彻底屏蔽不显示。
// 3. 【处理标题和描述】
$raw_title = empty($r['oldtitle']) ? $r['title'] : $r['oldtitle'];
$safe_title = htmlspecialchars(strip_tags($raw_title), ENT_QUOTES);
$safe_desc = htmlspecialchars(strip_tags($r['smalltext']), ENT_QUOTES);
// 4. 【智能判断图片】
$has_pic = !empty($r['titlepic']);
$pic_class = $has_pic ? '' : 'no-pic'; // 没图时加上 no-pic 类名让文字拉伸
$pic_html = '';
if ($has_pic) {
// 有图片才输出这块 HTML,同时把 aria-label 改成了通用的“查看详情”
$pic_html = '
'.$r['xllx'].'
';
}
// 5. 【拼接最终的 HTML 输出】
$listtemp = '
'.$pic_html.'
'.$safe_desc.'...
'.$address_html.'
'.$show_price.'
关注度:'.$r['onclick'].' 人
查看详情
';
// 1. 【智能判断价格与单位】
$price = 0;
$unit = '';
if (!empty($r['qijia']) && $r['qijia'] > 0) {
// 如果有起价(qijia),说明是酒店,显示 元/间
$price = $r['qijia'];
$unit = '元/间';
} elseif (!empty($r['mpjg']) && $r['mpjg'] > 0) {
// 如果有门票价格(mpjg),说明是景点,单位隐藏为空
$price = $r['mpjg'];
$unit = '';
}
if (empty($price) || $price == '0.00') {
$show_price = ''; // 价格为空或0,直接不显示
} else {
$show_price = '¥
'.$price.''.$unit;
}
// 2. 【智能判断地址类型】
$address_html = '';
if (!empty(trim($r['jddz']))) {
// 如果有 jddz,显示酒店地址
$address_html = '
酒店地址:'.$r['jddz'].'';
} elseif (!empty(trim($r['jdxxdz']))) {
// 如果有 jdxxdz,显示景点地址
$address_html = '
景点地址:'.$r['jdxxdz'].'';
}
// 如果上面两个都是空的,$address_html 就是空的,彻底屏蔽不显示。
// 3. 【处理标题和描述】
$raw_title = empty($r['oldtitle']) ? $r['title'] : $r['oldtitle'];
$safe_title = htmlspecialchars(strip_tags($raw_title), ENT_QUOTES);
$safe_desc = htmlspecialchars(strip_tags($r['smalltext']), ENT_QUOTES);
// 4. 【智能判断图片】
$has_pic = !empty($r['titlepic']);
$pic_class = $has_pic ? '' : 'no-pic'; // 没图时加上 no-pic 类名让文字拉伸
$pic_html = '';
if ($has_pic) {
// 有图片才输出这块 HTML,同时把 aria-label 改成了通用的“查看详情”
$pic_html = '
'.$r['xllx'].'
';
}
// 5. 【拼接最终的 HTML 输出】
$listtemp = '
'.$pic_html.'
'.$safe_desc.'...
'.$address_html.'
'.$show_price.'
关注度:'.$r['onclick'].' 人
查看详情
';
// 1. 【智能判断价格与单位】
$price = 0;
$unit = '';
if (!empty($r['qijia']) && $r['qijia'] > 0) {
// 如果有起价(qijia),说明是酒店,显示 元/间
$price = $r['qijia'];
$unit = '元/间';
} elseif (!empty($r['mpjg']) && $r['mpjg'] > 0) {
// 如果有门票价格(mpjg),说明是景点,单位隐藏为空
$price = $r['mpjg'];
$unit = '';
}
if (empty($price) || $price == '0.00') {
$show_price = ''; // 价格为空或0,直接不显示
} else {
$show_price = '¥
'.$price.''.$unit;
}
// 2. 【智能判断地址类型】
$address_html = '';
if (!empty(trim($r['jddz']))) {
// 如果有 jddz,显示酒店地址
$address_html = '
酒店地址:'.$r['jddz'].'';
} elseif (!empty(trim($r['jdxxdz']))) {
// 如果有 jdxxdz,显示景点地址
$address_html = '
景点地址:'.$r['jdxxdz'].'';
}
// 如果上面两个都是空的,$address_html 就是空的,彻底屏蔽不显示。
// 3. 【处理标题和描述】
$raw_title = empty($r['oldtitle']) ? $r['title'] : $r['oldtitle'];
$safe_title = htmlspecialchars(strip_tags($raw_title), ENT_QUOTES);
$safe_desc = htmlspecialchars(strip_tags($r['smalltext']), ENT_QUOTES);
// 4. 【智能判断图片】
$has_pic = !empty($r['titlepic']);
$pic_class = $has_pic ? '' : 'no-pic'; // 没图时加上 no-pic 类名让文字拉伸
$pic_html = '';
if ($has_pic) {
// 有图片才输出这块 HTML,同时把 aria-label 改成了通用的“查看详情”
$pic_html = '
'.$r['xllx'].'
';
}
// 5. 【拼接最终的 HTML 输出】
$listtemp = '
'.$pic_html.'
'.$safe_desc.'...
'.$address_html.'
'.$show_price.'
关注度:'.$r['onclick'].' 人
查看详情
';
// 1. 【智能判断价格与单位】
$price = 0;
$unit = '';
if (!empty($r['qijia']) && $r['qijia'] > 0) {
// 如果有起价(qijia),说明是酒店,显示 元/间
$price = $r['qijia'];
$unit = '元/间';
} elseif (!empty($r['mpjg']) && $r['mpjg'] > 0) {
// 如果有门票价格(mpjg),说明是景点,单位隐藏为空
$price = $r['mpjg'];
$unit = '';
}
if (empty($price) || $price == '0.00') {
$show_price = ''; // 价格为空或0,直接不显示
} else {
$show_price = '¥
'.$price.''.$unit;
}
// 2. 【智能判断地址类型】
$address_html = '';
if (!empty(trim($r['jddz']))) {
// 如果有 jddz,显示酒店地址
$address_html = '
酒店地址:'.$r['jddz'].'';
} elseif (!empty(trim($r['jdxxdz']))) {
// 如果有 jdxxdz,显示景点地址
$address_html = '
景点地址:'.$r['jdxxdz'].'';
}
// 如果上面两个都是空的,$address_html 就是空的,彻底屏蔽不显示。
// 3. 【处理标题和描述】
$raw_title = empty($r['oldtitle']) ? $r['title'] : $r['oldtitle'];
$safe_title = htmlspecialchars(strip_tags($raw_title), ENT_QUOTES);
$safe_desc = htmlspecialchars(strip_tags($r['smalltext']), ENT_QUOTES);
// 4. 【智能判断图片】
$has_pic = !empty($r['titlepic']);
$pic_class = $has_pic ? '' : 'no-pic'; // 没图时加上 no-pic 类名让文字拉伸
$pic_html = '';
if ($has_pic) {
// 有图片才输出这块 HTML,同时把 aria-label 改成了通用的“查看详情”
$pic_html = '
'.$r['xllx'].'
';
}
// 5. 【拼接最终的 HTML 输出】
$listtemp = '
'.$pic_html.'
'.$safe_desc.'...
'.$address_html.'
'.$show_price.'
关注度:'.$r['onclick'].' 人
查看详情
';