-1

我的页面上有一个彩色色板区域(以及 AVAIALBLE COLOURS 瓷砖),我只想在数据库中有结果时才显示。

这是我的代码:

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;
}
4

1 回答 1

1

简单使用css

div:empty
{display:none;}
于 2012-07-21T15:03:03.893 回答