我的页面上有一个彩色色板(和瓷砖可用颜色)的区域,如果数据库中有结果,我只想显示它。
这是我的代码:
private function getWTVariationHighlights($productId, $variationId)
{
$output_str = "";
$output_str .="<div class=\"mainProductSwatchesTitle\"><b>AVAILABLE COLOURS</b>\n";
$output_str .= "<div class=\"mainProductSwatches\">\n";
$sql = "select voptionid, vovalue from [|PREFIX|]product_variation_options where vovariationid=$variationId and (voname='Colour' or voname='Color')";
$result = $this->db->Query($sql);
while ($row = $this->db->fetch($result)) {
$sql = "select * from [|PREFIX|]variation_option_highlight where variation_option_id=" . $row['voptionid'] . " and product_id=" . $productId;
$result2 = $this->db->Query($sql);
if($row2 = $this->db->fetch($result2)){
if($row2['thumb_location']){
$output_str .= "<a href=\"#\" onmouseover=\"changeMain('" . $row2['location'] . "')\"><img src=\""
. $GLOBALS['ShopPath'] . "/product_images/hfh_highlight_images/" . $row2['thumb_location'] . "\" /></a>\n";
}
}
}
$output_str .= "</div>\n";
$output_str .= "<script type=\"text/javascript\">\n";
$output_str .= "function changeMain(src)\n";
$output_str .= "{\n";
$output_str .= "document.getElementById('phthumb').src = '" . $GLOBALS['ShopPath'] . "/product_images/hfh_highlight_images/' + src;\n";
$output_str .= "}\n";
$output_str .= "</script>\n";
return $output_str;
}
答案 0 :(得分:1)
简单使用css
div:empty
{display:none;}