我写一个无限级分类下拉功能,到下面这个代码老是报错,折腾一天了,求高手看看。
$str_select.= "<option value=" .$row['classid'] if ($classid == $row['classid']){ echo "selected"}.">" .str_repeat( "-" ,$depth) . $row['classname']."</option>"; //字符串构建
错误提示:Parse error: syntax error, unexpected T_IF
------解决思路----------------------
$str_select .= "<option value=" .$row['classid'] . ($classid == $row['classid'] ? "selected" : '') .">" .str_repeat( "-" ,$depth) . $row['classname']."</option>"; //字符串构建