<? if (isset($menu_filter_sizes)) { ?>
<? for ($i = 0; $i < count($menu_filter_sizes); $i++) { ?>
<? if (!empty($menu_filter_sizes[$i]['name'])) { ?>
<li>
<? if ($page->sp_size == $menu_filter_sizes[$i]['id']) { ?>
<? } else { ?><a href=""><? }; ?>
<? echo $menu_filter_sizes[$i]['name']; ?>
<? if ($page->sp_size == $menu_filter_sizes[$i]['id']) { ?>
<? } else { ?></a><? }; ?>
(<? echo $menu_filter_sizes[$i]['quantity']; ?>)
</li>
<? }; ?>
<? }; ?>
<? }; ?>
此代码生成具有不同值(例如大小)的列表。我在我的数据库中有一个名为"Nosize"的值。这是没有尺寸的产品的价值。呈现我拥有的 PHP 代码输出列表中的所有值。
如何使用 php 以名称“Nosize”隐藏该值???并仅显示其他值。换句话说,显示除“Nosize”之外的所有值。
MYSQL:
function GetShopFilterSizes($shopid,$category,$fcolor,$fbrand,$fytpe,$fpricefrom,$fpriceto){
$thisdate = date("Y-m-d H:i:s", time());
$sqlquery = "SELECT DISTINCT($this->basesq.size) AS id, $this->basesize.alias, $this->basesizelang.name, COUNT(DISTINCT($this->base.id)) as quantity FROM $this->base LEFT JOIN $this->basesq ON $this->basesq.productid = $this->base.id LEFT JOIN $this->basesize ON $this->basesq.size = $this->basesize.id LEFT JOIN $this->basesizelang ON $this->basesize.id = $this->basesizelang.sizeid AND $this->basesizelang.lang = '".sql($this->thislang)."' WHERE $this->base.shopid = '".Sql($shopid)."' AND $this->base.exist = 1 AND $this->base.active = 1 AND $this->base.isdeleted = 0";
if (count($category) > 0) {$sqlquery .= " AND (";};
for ($i = 0; $i < count($category); $i++) {
if ($i == 0) {$sqlquery .= "$this->base.categoryid = '".sql($category[$i])."'";}
else {$sqlquery .= " OR $this->base.categoryid = '".sql($category[$i])."'";};
};
if (count($category) > 0) {$sqlquery .= ")";};
if (!empty($fbrand)) {$sqlquery .= " AND $this->base.brand = '".sql($fbrand)."'";};
if (!empty($ftype)) {$sqlquery .= " AND $this->base.type = '".sql($ftype)."'";};
if (!empty($fcolor)) {$sqlquery .= " AND $this->basesq.color = '".sql($fcolor)."' AND $this->basesp.quantity > '0'";};
if (!empty($fpricefrom)) {$sqlquery .= " AND ($this->base.price >= '".sql($fpricefrom)."')";};
if (!empty($fpriceto)) {
$sqlquery .= " AND (
($this->base.price <= '".sql($fpriceto)."') OR ($this->base.specialprice IS NOT NULL AND $this->base.specialprice < '".sql($fpriceto)."') OR ($this->base.salesprice IS NOT NULL AND $this->base.salesprice < '".sql($fpriceto)."' AND (($this->base.slprice_datestart IS NULL OR $this->base.slprice_datestart < '".$thisdate."') AND ($this->base.slprice_dateend IS NULL OR $this->base.slprice_dateend > '".$thisdate."')))
)";
};
$sqlquery .= " GROUP BY $this->basesq.size";
$result = mysql_query($sqlquery) or die(mysql_error()." in file: ".__FILE__.", line: ".__LINE__);
return GetMySQLResultArray($result);
}
整个 HTML 文本
<div class="box manufacturers">
<div class="box-heading" style="border-bottom: 1px solid #d8dae5;"><span><? echo $langdata['prlist_size']; ?></span></div>
<? if (isset($menu_filter_sizes)) { ?>
<div class="box-content">
<ul>
<? for ($i = 0; $i < count($menu_filter_sizes); $i++) { ?>
<? if($menu_filter_sizes[$i]['name']!='nosize') { ?>
<li>
<? if ($page->sp_size == $menu_filter_sizes[$i]['id']) { ?><u>
<? } else { ?><a href="<? echo ClearURL(array('success','size'),array('_size='.$menu_filter_sizes[$i]['alias'])); ?>"><? }; ?>
<? echo $menu_filter_sizes[$i]['name']; ?>
<? if ($page->sp_size == $menu_filter_sizes[$i]['id']) { ?></u>
<? } else { ?></a><? }; ?>
</strong> (<? echo $menu_filter_sizes[$i]['quantity']; ?>)
</li>
<?}else{?>
<? }; ?>
<? }; ?>
</ul>
</div>
<? }; ?>
</div>