提前致謝。顯示當前分類名稱
我想顯示當前類別的,我在沒有,我一直在嘗試4小時,現在已經工作很名字..
我的代碼:
if($catList) {
$c = 0;
while($category = $catList->fetch(PDO::FETCH_ASSOC)){
$margintop = 38*$c;
if($category['id'] == $thiscategory) {
echo "<a href='".$link."&category=".$category['id']."'>
<div class='category_name'>".strip_tags($category['name']). "</div></a></div>";
} else {
echo "<a href='".$link."&category=".$category['id']."'>
<div class='category_name'>".strip_tags($category['name']). "</div></a></div>";
}
$c++;
}
} else {
echo "No categories to show.";
}
我試圖獲得當前類別名稱,在頁面的不同區域:
if($category['id'] == $thiscategory) {
echo ".strip_tags($category[name])." ;
}
它給出了一個空白的結果。
var_dump()都是$ category和$ thiscategory,以確保兩者都是popu並且它們包含你期望的內容 – Blinkydamo
你檢查了'$ category ['id']'和$ $ thiscategory'變量中的值嗎? – Yash
'$ thiscategory'返回類別id,而不是名稱。 $ category ['id']不會返回任何內容..空結果 – blitzers997197